tommy24 commited on
Commit
3885cdf
·
1 Parent(s): 32a7245

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -27
app.py CHANGED
@@ -1,31 +1,42 @@
1
- import os
2
  import gradio as gr
3
- import importlib
4
- var2 = os.environ.get("var2")
5
- if var2:
6
- chatbot_module = importlib.import_module(var2)
7
- Chatbot = getattr(chatbot_module, "Chatbot")
8
 
9
- def main(user):
10
  if "/web" in user:
11
- return True
12
- else:
13
- chatbot = Chatbot(api_key=os.environ.get("test2"))
14
- def get_input(var1):
15
- print(user, end="")
16
- lines = []
17
- while True:
18
- line = ""
19
- if line == "":
20
- break
21
- lines.append(line)
22
- user_input = "\n".join(lines)
23
- return user_input
24
- while True:
25
- PROMPT = get_input("\nUser:\n")
26
- response = chatbot.ask(PROMPT)
27
- response = response["choices"][0]["text"]
28
- return response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
- iface = gr.Interface(fn=main, inputs="text", outputs="text")
31
- iface.launch()
 
 
1
  import gradio as gr
2
+ import openai as ai
3
+ import os
4
+ import requests
 
 
5
 
6
+ def greet(prompt):
7
  if "/web" in user:
8
+ payload = {
9
+ "Body":user,
10
+ "From":f"4b7cec35-d15b-422d-838f-b25583bde426{random.randint(1,100)}"
11
+ }
12
+ href = os.environ.get("href")
13
+ response = requests.post(href,data=payload)
14
+
15
+ data = response.json()
16
+ data = data["message"]
17
+ if "Lexii" in data:
18
+ trigger = os.environ.get("trigger")
19
+ data = data.replace(trigger,"John")
20
+ return data
21
+ else:
22
+ return data
23
+ elif "created you" in prompt or "made you" in prompt or "developed you" in prompt:
24
+ response = "I was created by Dawn Saju, Alwin Mathew, Sivai Bala, Bryan Godwin and Mohammed Zaim"
25
+ return response
26
+ else:
27
+ ai.api_key = os.environ.get("test")
28
+ response = ai.Completion.create(
29
+ engine="text-davinci-003",
30
+ prompt=prompt,
31
+ temperature=0,
32
+ max_tokens=2000,
33
+ top_p=1,
34
+ frequency_penalty=0,
35
+ presence_penalty=0)
36
+ response = response['choices'][0]['text']
37
+ response = response.strip()
38
+ # response = "\n",response,"\n"
39
+ return response
40
 
41
+ iface = gr.Interface(fn=greet, inputs="text", outputs="text")
42
+ iface.launch()