from openai import OpenAI from .tools import tools from .utils import system_prompt, handle_tool_calls # okay now we have app file I got it from smola agent its a taste file I have agent use that agent and add that agent in app in such a way that api come with questions and this agent give answers check how app file is made you will undertand dont change structure and way and logis ogf app file # Initialize OpenAI client client = OpenAI( api_key="sk-60c49cf5d82a4d4bb0a6c111eeafe941", base_url="https://api.deepseek.com" ) def chat_with_agent(user_message): """Main function to chat with the agent - gives short, concise responses""" messages = [ {"role": "system", "content": system_prompt}, {"role": "user", "content": user_message} ] while True: # Get response from LLM with token limits response = client.chat.completions.create( model="deepseek-chat", messages=messages, tools=tools, ) # Add the assistant's response to messages messages.append(response.choices[0].message) # Handle tool calls if any tool_results = handle_tool_calls(response) if tool_results: # Add tool results to messages messages.extend(tool_results) # Add a reminder for the final response to be short messages.append({ "role": "system", "content": "Remember: Give a SHORT summary (2-3 lines max) of the tool results. Focus on key points only." }) # Continue the conversation (the LLM will respond to the tool results) continue else: # No tool calls, return the final response return response.choices[0].message.content # def interactive_chat(): # """Interactive chat interface with short responses""" # print("šŸ¤– Welcome to the AI Agent!") # print("I'll give you short, concise answers.") # print("Type 'quit' to exit.") # print("-" * 50) # while True: # user_input = input("\nšŸ‘¤ You: ").strip() # if user_input.lower() in ['quit', 'exit', 'bye', 'q']: # print("šŸ¤– Goodbye!") # break # if not user_input: # continue # try: # print("šŸ¤– Thinking...") # response = chat_with_agent(user_input) # print(f"šŸ¤– Assistant: {response}") # except Exception as e: # print(f"šŸ¤– Error: {str(e)}") # Example usage # if __name__ == "__main__": # # Interactive mode # interactive_chat() # Uncomment for testing with specific questions # user_question = "What's the weather like in Mumbai?" # print(f"User: {user_question}") # answer = chat_with_agent(user_question) # print(f"Assistant: {answer}") print(chat_with_agent("tech news today"))