Spaces:
Sleeping
Sleeping
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() | |