File size: 652 Bytes
967b840
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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