File size: 758 Bytes
5463463
d3f1a70
 
5463463
 
d3f1a70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
import gradio as gr
import openai
import os


llm_model = 'gpt-3.5-turbo-0125'
openai.api_key = os.environ['OPENAI_API_KEY']


def get_completion(prompt, model=llm_model):
    messages = [{"role": "user", "content": prompt}]
    response = openai.ChatCompletion.create(
        model=model,
        messages=messages,
        temperature=0, 
    )
    return response.choices[0].message["content"]

def find_orgs(sentence):
    prompt = f"""
    Find all organizations in the text delimited by triple backticks.
    
    text:
    ```
    {sentence}
    ```
    You should always start your answer with "Organizations are: "
    """
    return get_completion(prompt)

iface = gr.Interface(fn=find_orgs, inputs="text", outputs="text")
iface.launch(share=True)