mpolanco commited on
Commit
d6170b8
1 Parent(s): 1092f22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -23
app.py CHANGED
@@ -1,33 +1,34 @@
1
  import gradio as gr
2
  import requests
 
3
 
4
- def generate_response(prompt):
5
- endpoint = 'https://api.together.xyz/v1/chat/completions'
6
- headers = {
7
- "Authorization": "Bearer YOUR_API_KEY",
8
- }
9
- payload = {
10
- "model": "meta-llama/Llama-2-70b-chat-hf",
11
- "max_tokens": 512,
12
- "prompt": "[INST] {prompt} [/INST]",
13
- "request_type": "language-model-inference",
14
- "temperature": 0.7,
15
- "top_p": 0.7,
16
- "top_k": 50,
17
- "repetition_penalty": 1,
18
- "stop": ["[/INST]", ""],
19
- "promptObj": {"prompt": ""},
20
- }
21
- response = requests.post(endpoint, json=payload, headers=headers)
22
- return response.json()["choices"][0]["text"]
23
 
24
  iface = gr.Interface(
25
- fn=generate_response,
26
  inputs="text",
27
  outputs="text",
28
- title="Llama Chatbot",
29
- description="Chat with the Llama chatbot model.",
30
- example="What is the weather like today?",
31
  )
32
 
33
  iface.launch()
 
1
  import gradio as gr
2
  import requests
3
+ import json
4
 
5
+ def get_spell_correction(input_text):
6
+ response = requests.post(
7
+ "https://api.respell.ai/v1/run",
8
+ headers={
9
+ "Authorization": "Bearer 260cee54-6d54-48ba-92e8-bf641b5f4805",
10
+ "Accept": "application/json",
11
+ "Content-Type": "application/json"
12
+ },
13
+ data=json.dumps({
14
+ "spellId": "1th5Ic7ZnMmZXBtZCfR7-",
15
+ # This field can be omitted to run the latest published version
16
+ "spellVersionId": "-NTOo8UsyhC-3g52p7ExZ",
17
+ # Fill in a value for your dynamic input block
18
+ "inputs": {
19
+ "pregunta": input_text,
20
+ }
21
+ }),
22
+ )
23
+ return response.json()["results"]["corrections"]["pregunta"]["text"]
24
 
25
  iface = gr.Interface(
26
+ fn=get_spell_correction,
27
  inputs="text",
28
  outputs="text",
29
+ title="Respell Spell Checker",
30
+ description="Correct spelling using the Respell API.",
31
+ example="Enter your text here...",
32
  )
33
 
34
  iface.launch()