Spaces:
Runtime error
Runtime error
Update app.py
Browse files16 unmodified lines171819202122232 unmodified lines26272829303184 unmodified lines11611711811912012112212312412512612722 unmodified lines15015115215315415522 unmodified lines1781791801811821831848 unmodified lines19319419519616 unmodified lineswith open(image_path, "rb") as image_file:return base64.b64encode(image_file.read()).decode('utf-8')def bot_streaming(message, history, api_key, model, temperature, max_tokens, top_p, top_k, frequency_penalty, presence_penalty, repetition_penalty, stop, min_p, top_a, seed, logit_bias, logprobs, top_logprobs, response_format, tools, tool_choice):headers = {"Authorization": f"Bearer {api_key}","Content-Type": "application/json"2 unmodified linesmessages = []images = []for i, msg in enumerate(history):if isinstance(msg[0], tuple):image, text = msg[0]84 unmodified lines2. Choose a model or enter a custom model name/endpoint3. Start chatting!## 🔧 Settings:- Adjust basic parameters in the "Common Settings" section- Fine-tune options in the "Advanced Settings" section- Access expert-level controls in the "Expert Settings" section- Upload images for multimodal interactionsEnjoy your AI-powered conversation!""")22 unmodified linesvalue="google/gemini-flash-1.5",allow_custom_value=True)with gr.Accordion("Common Settings", open=False):temperature = gr.Slider(minimum=0, maximum=2, value=1, step=0.1, label="Temperature")22 unmodified lineschatbot = gr.ChatInterface(fn=bot_streaming,additional_inputs=[api_key, model, temperature, max_tokens, top_p, top_k,frequency_penalty, presence_penalty, repetition_penalty, stop,min_p, top_a, seed, logit_bias, logprobs, top_logprobs,response_format, tools, tool_choice8 unmodified linesfill_height=True,)demo.launch(debug=True, share=True)16 unmodified lines171819202122232 unmodified lines26272829303132333484 unmodified lines11912012112212312422 unmodified lines14714814915015115215322 unmodified lines1761771781791801811828 unmodified lines19119219319419519619719819920020120216 unmodified lineswith open(image_path, "rb") as image_file:return base64.b64encode(image_file.read()).decode('utf-8')def bot_streaming(message, history, api_key, model, system_prompt, temperature, max_tokens, top_p, top_k, frequency_penalty, presence_penalty, repetition_penalty, stop, min_p, top_a, seed, logit_bias, logprobs, top_logprobs, response_format, tools, tool_choice):headers = {"Authorization": f"Bearer {api_key}","Content-Type": "application/json"2 unmodified linesmessages = []images = []if system_prompt:messages.append({"role": "system", "content": system_prompt})for i, msg in enumerate(history):if isinstance(msg[0], tuple):image, text = msg[0]84 unmodified lines2. Choose a model or enter a custom model name/endpoint3. Start chatting!Enjoy your AI-powered conversation!""")22 unmodified linesvalue="google/gemini-flash-1.5",allow_custom_value=True)system_prompt = gr.Textbox(label="System Prompt", placeholder="Enter a system prompt (optional)")with gr.Accordion("Common Settings", open=False):temperature = gr.Slider(minimum=0, maximum=2, value=1, step=0.1, label="Temperature")22 unmodified lineschatbot = gr.ChatInterface(fn=bot_streaming,additional_inputs=[api_key, model, system_prompt, temperature, max_tokens, top_p, top_k,frequency_penalty, presence_penalty, repetition_penalty, stop,min_p, top_a, seed, logit_bias, logprobs, top_logprobs,response_format, tools, tool_choice8 unmodified linesfill_height=True,)gr.Markdown("""## 🔧 Settings:- Adjust basic parameters in the "Common Settings" section- Fine-tune options in the "Advanced Settings" section- Access expert-level controls in the "Expert Settings" section- Upload images for multimodal interactions""")demo.launch(debug=True, share=True)
app.py+14-8