import requests import gradio as gr import json def get_text_response(prompt): api_url = "http://35.233.231.20:5003/api/generate" data_payload = { "model": "llama3", "prompt": prompt, "stream": True } full_response = "" with requests.post(api_url, json=data_payload, stream=True) as response: for line in response.iter_lines(): if line: decoded_line = line.decode('utf-8') json_line = decoded_line.strip(',') try: response_json = json.loads(json_line) text_response = response_json.get("response", "") done = response_json.get("done", False) full_response += text_response yield full_response if done: break except json.JSONDecodeError as e: continue def clear_chat(): return "", "" css = """ """ with gr.Blocks(css=css) as demo: gr.HTML( """
Run AI models on your home computers, powered by FairCompute