Weather-App / findCity.py
kayyshf's picture
created findCity.py It takes the user input as string and returns the city mentioned in the query.
967b840 verified
raw
history blame
652 Bytes
from groq import Groq
import os
from dotenv import load_dotenv
load_dotenv()
def find_city(input_string):
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
completion = client.chat.completions.create(
model="llama3-8b-8192",
messages=[
{
"role": "system",
"content": "you are a geography expert. return just a one word city name from the sentence given to you"
},
{
"role": "user",
"content": input_string,
}
],
max_tokens=100,
)
city = completion.choices[0].message.content
return city