debisoft commited on
Commit
6a71e3a
·
1 Parent(s): cab9beb

Initial Commit!

Browse files
Files changed (2) hide show
  1. app.py +36 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import os
3
+ import gradio as gr
4
+ import json
5
+ from dotenv import load_dotenv, find_dotenv
6
+ _ = load_dotenv(find_dotenv())
7
+
8
+
9
+ openai.api_key = os.getenv('OPENAI_API_KEY')
10
+
11
+ def get_completion(prompt, model="gpt-3.5-turbo"):
12
+ messages = [{"role": "user", "content": prompt}]
13
+ response = openai.ChatCompletion.create(
14
+ model=model,
15
+ messages=messages,
16
+ temperature=0, # this is the degree of randomness of the model's output
17
+ )
18
+ return response.choices[0].message["content"]
19
+
20
+ def greet(input):
21
+ prompt = f"""
22
+ Recommend complementary shops specifically for the shop(s) described in the following text, ranked by synergy: \
23
+ Text: ```{input}```
24
+ """
25
+
26
+ response = get_completion(prompt)
27
+ print(response)
28
+ response = get_completion(prompt)
29
+ return response
30
+
31
+ #iface = gr.Interface(fn=greet, inputs="text", outputs="text")
32
+ #iface.launch()
33
+
34
+ #iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Text to find entities", lines=2)], outputs=[gr.HighlightedText(label="Text with entities")], title="NER with dslim/bert-base-NER", description="Find entities using the `dslim/bert-base-NER` model under the hood!", allow_flagging="never", examples=["My name is Andrew and I live in California", "My name is Poli and work at HuggingFace"])
35
+ iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Retail Business", lines=3)], outputs="text")
36
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ openai
2
+ python-dotenv