martianband1t commited on
Commit
5f14121
1 Parent(s): 9e78905

Update App.py

Browse files
Files changed (1) hide show
  1. App.py +0 -52
App.py CHANGED
@@ -1,54 +1,2 @@
1
  import streamlit as st
2
- import requests
3
- import googlemaps
4
  import openai
5
-
6
- # Configuration des clés API
7
- openai.api_key = 'VOTRE_CLE_API_OPENAI'
8
- google_maps_api_key = 'VOTRE_CLE_API_GOOGLE_MAPS'
9
-
10
- # Initialisation du client Google Maps
11
- gmaps = googlemaps.Client(key=google_maps_api_key)
12
-
13
- # Fonction pour obtenir les directions
14
- def get_directions(origin, destination):
15
- directions_result = gmaps.directions(origin, destination, mode="driving")
16
- if directions_result:
17
- return directions_result[0]
18
- else:
19
- return None
20
-
21
- # Fonction pour interagir avec l'assistant GPT
22
- def get_route_from_gpt(address, destination):
23
- response = openai.Completion.create(
24
- model="text-davinci-002",
25
- prompt=f"User address: {address}\nDestination: {destination}\nProvide the route, time of arrival, and display the itinerary on the map.",
26
- max_tokens=150
27
- )
28
- return response.choices[0].text
29
-
30
- # Interface utilisateur avec Streamlit
31
- st.title('Assistant GPT avec Carte Interactive')
32
-
33
- address = st.text_input('Votre adresse', 'Paris, France')
34
- destination = st.text_input('Destination', 'Lyon, France')
35
-
36
- if st.button('Obtenir l\'itinéraire'):
37
- directions = get_directions(address, destination)
38
- if directions:
39
- st.subheader('Itinéraire :')
40
- for step in directions['legs'][0]['steps']:
41
- st.markdown(step['html_instructions'], unsafe_allow_html=True)
42
-
43
- # Affichage de la carte avec l'itinéraire
44
- st.map({
45
- 'lat': directions['legs'][0]['start_location']['lat'],
46
- 'lon': directions['legs'][0]['start_location']['lng']
47
- })
48
-
49
- # Interaction avec GPT pour obtenir plus de détails
50
- gpt_response = get_route_from_gpt(address, destination)
51
- st.subheader('Détails supplémentaires :')
52
- st.write(gpt_response)
53
- else:
54
- st.error('Aucun itinéraire trouvé.')
 
1
  import streamlit as st
 
 
2
  import openai