Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,13 +23,16 @@ def generate_signature():
|
|
| 23 |
# Function to get geo-coordinates from a location name using OpenAI API
|
| 24 |
def get_coordinates(location_name):
|
| 25 |
prompt = f"Provide the latitude and longitude for {location_name}."
|
| 26 |
-
response = openai.
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
| 30 |
temperature=0
|
| 31 |
)
|
| 32 |
-
result = response.choices[0].
|
| 33 |
coordinates = result.split(",")
|
| 34 |
return float(coordinates[0]), float(coordinates[1])
|
| 35 |
|
|
|
|
| 23 |
# Function to get geo-coordinates from a location name using OpenAI API
|
| 24 |
def get_coordinates(location_name):
|
| 25 |
prompt = f"Provide the latitude and longitude for {location_name}."
|
| 26 |
+
response = openai.ChatCompletion.create(
|
| 27 |
+
model="gpt-3.5-turbo",
|
| 28 |
+
messages=[
|
| 29 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 30 |
+
{"role": "user", "content": prompt}
|
| 31 |
+
],
|
| 32 |
+
max_tokens=50,
|
| 33 |
temperature=0
|
| 34 |
)
|
| 35 |
+
result = response.choices[0].message['content'].strip()
|
| 36 |
coordinates = result.split(",")
|
| 37 |
return float(coordinates[0]), float(coordinates[1])
|
| 38 |
|