Spaces:
Sleeping
Sleeping
File size: 1,027 Bytes
d435c86 f5b9b37 d435c86 efd2301 |
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 33 34 |
import requests
import gradio as gr
def get_text_response(prompt):
api_url = "http://35.233.231.20:5002/api/generate"
data_payload = {
"model": "llama2",
"prompt": prompt,
"stream": False
}
response = requests.post(api_url, json=data_payload)
response_json = response.json()
text_response = response_json.get("response", "No response received.")
return text_response
with gr.Blocks() as demo:
with gr.Row():
prompt = gr.Textbox(label="Enter your prompt")
submit_button = gr.Button("Submit")
output = gr.Textbox(label="Response")
submit_button.click(fn=get_text_response, inputs=prompt, outputs=output)
# Adding the acknowledgment about Fair Compute
gr.HTML(
"""
<div class="acknowledgments">
<p>Run AI models on your home computers, powered by <a href="https://faircompute.com/" style="text-decoration: underline;" target="_blank">FairCompute</a></p>
</div>
"""
)
demo.launch()
|