nick1221/system1
0
1import gradio as gr2from system1 import System13import os4 5# Define the default model provider and default agent type6default_model = "bedrock-chat:anthropic.claude-3-sonnet-20240229-v1:0"7#default_model = "bedrock-chat:mistral.mistral-large-2402-v1:0"8#default_model = "bedrock:cohere.command-r-plus-v1:0"9 10 11default_agent_type = "structured"12 13def create_vector_interface():14 provider, model_id = default_model.split(':', 1)15 16 17# Custom CSS to make the element scale to the size of the screen18custom_css = """19#chat-interface {20 height: 100vh !important;21}22"""23 24vector = System1(llm_provider="openai", model_id="gpt-4o", agent_type=default_agent_type)25chat_history = []26 27with gr.Blocks(css=custom_css, fill_height=True) as app:28 def chat(message, history):29 30 try:31 chat_history.append(("human", message))32 response_messages = vector.chat_messages(chat_history)33 bot_message = response_messages['messages'][-1].content if response_messages['messages'] else "No messages found"34 chat_history.append(("ai", bot_message))35 return bot_message36 37 except Exception as e:38 return f"An error occurred: {str(e)}"39 40 chat_interface = gr.ChatInterface(41 fn=chat, 42 title="TrustStack AI", 43 examples=[44 "Show me all issues in project VE",45 "Tell me the description of the issues in project ADVICE",46 "List all projects",47 "When was the last update on the ticket VE-4",48 "Describe the capabilities of the JIRA integration tools"49 ],50 theme=gr.themes.Soft(),51 fill_height=True52 )53 54app.launch(server_port=int(os.getenv("GRADIO_SERVER_PORT")), share=True)55 56 