curiouscurrent commited on
Commit
55b6c6c
·
verified ·
1 Parent(s): 56a046c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -22
app.py CHANGED
@@ -2,39 +2,38 @@ import requests
2
  import json
3
  import gradio as gr
4
 
5
- url="https://huggingface.co/curiouscurrent/omnicode"
6
 
7
- headers={
8
-
9
- 'Content-Type':'application/json'
10
  }
11
 
12
- history=[]
13
 
14
  def generate_response(prompt):
 
15
  history.append(prompt)
16
- final_prompt="\n".join(history)
17
-
18
- data={
19
- "model":"curiouscurrent/omnicode",
20
- "prompt":final_prompt,
21
- "stream":False
22
  }
 
23
 
24
- response=requests.post(url,headers=headers,data=json.dumps(data))
25
-
26
- if response.status_code==200:
27
- response=response.text
28
- data=json.loads(response)
29
- actual_response=data['response']
30
  return actual_response
31
  else:
32
- print("error:",response.text)
33
 
34
 
35
- interface=gr.Interface(
36
  fn=generate_response,
37
- inputs=gr.Textbox(lines=4,placeholder="Enter your Prompt"),
38
- outputs="text"
 
 
39
  )
40
- interface.launch()
 
2
  import json
3
  import gradio as gr
4
 
5
+ url = "https://huggingface.co/curiouscurrent/omnicode"
6
 
7
+ headers = {
8
+ 'Content-Type': 'application/json'
 
9
  }
10
 
11
+ history = []
12
 
13
  def generate_response(prompt):
14
+ global history
15
  history.append(prompt)
16
+ final_prompt = "\n".join(history)
17
+ data = {
18
+ "model": "curiouscurrent/omnicode",
19
+ "prompt": final_prompt,
20
+ "stream": False
 
21
  }
22
+ response = requests.post(url, headers=headers, data=json.dumps(data))
23
 
24
+ if response.status_code == 200:
25
+ response = response.json()
26
+ actual_response = response['response']
 
 
 
27
  return actual_response
28
  else:
29
+ print("error:", response.text)
30
 
31
 
32
+ interface = gr.Interface(
33
  fn=generate_response,
34
+ inputs=gr.Textbox(lines=4, placeholder="Enter your Prompt"),
35
+ outputs="text",
36
+ title="Omnicode",
37
+ description="A code generation model trained on a variety of programming languages."
38
  )
39
+ interface.launch()