diff --git a/image-gen/.env.example b/archive/agent-image-editing/.env.example similarity index 100% rename from image-gen/.env.example rename to archive/agent-image-editing/.env.example diff --git a/image-gen/README.md b/archive/agent-image-editing/README.md similarity index 100% rename from image-gen/README.md rename to archive/agent-image-editing/README.md diff --git a/image-gen/app.py b/archive/agent-image-editing/app.py similarity index 100% rename from image-gen/app.py rename to archive/agent-image-editing/app.py diff --git a/image-gen/chainlit.md b/archive/agent-image-editing/chainlit.md similarity index 100% rename from image-gen/chainlit.md rename to archive/agent-image-editing/chainlit.md diff --git a/image-gen/rendering.png b/archive/agent-image-editing/rendering.png similarity index 100% rename from image-gen/rendering.png rename to archive/agent-image-editing/rendering.png diff --git a/image-gen/requirements.txt b/archive/agent-image-editing/requirements.txt similarity index 100% rename from image-gen/requirements.txt rename to archive/agent-image-editing/requirements.txt diff --git a/image-gen/tools.py b/archive/agent-image-editing/tools.py similarity index 100% rename from image-gen/tools.py rename to archive/agent-image-editing/tools.py diff --git a/groq-llama3-llamaindex-hf/.env.example b/archive/groq-llama3-llamaindex-hf/.env.example similarity index 100% rename from groq-llama3-llamaindex-hf/.env.example rename to archive/groq-llama3-llamaindex-hf/.env.example diff --git a/groq-llama3-llamaindex-hf/Dockerfile b/archive/groq-llama3-llamaindex-hf/Dockerfile similarity index 100% rename from groq-llama3-llamaindex-hf/Dockerfile rename to archive/groq-llama3-llamaindex-hf/Dockerfile diff --git a/groq-llama3-llamaindex-hf/README.md b/archive/groq-llama3-llamaindex-hf/README.md similarity index 100% rename from groq-llama3-llamaindex-hf/README.md rename to archive/groq-llama3-llamaindex-hf/README.md diff --git a/groq-llama3-llamaindex-hf/app.py b/archive/groq-llama3-llamaindex-hf/app.py similarity index 100% rename from groq-llama3-llamaindex-hf/app.py rename to archive/groq-llama3-llamaindex-hf/app.py diff --git a/groq-llama3-llamaindex-hf/chainlit.md b/archive/groq-llama3-llamaindex-hf/chainlit.md similarity index 100% rename from groq-llama3-llamaindex-hf/chainlit.md rename to archive/groq-llama3-llamaindex-hf/chainlit.md diff --git a/groq-llama3-llamaindex-hf/data/Basics_of_finance.pdf b/archive/groq-llama3-llamaindex-hf/data/Basics_of_finance.pdf similarity index 100% rename from groq-llama3-llamaindex-hf/data/Basics_of_finance.pdf rename to archive/groq-llama3-llamaindex-hf/data/Basics_of_finance.pdf diff --git a/groq-llama3-llamaindex-hf/requirements.txt b/archive/groq-llama3-llamaindex-hf/requirements.txt similarity index 100% rename from groq-llama3-llamaindex-hf/requirements.txt rename to archive/groq-llama3-llamaindex-hf/requirements.txt diff --git a/haystack/.env.example b/archive/haystack/.env.example similarity index 100% rename from haystack/.env.example rename to archive/haystack/.env.example diff --git a/haystack/README.md b/archive/haystack/README.md similarity index 100% rename from haystack/README.md rename to archive/haystack/README.md diff --git a/haystack/Screenshot.png b/archive/haystack/Screenshot.png similarity index 100% rename from haystack/Screenshot.png rename to archive/haystack/Screenshot.png diff --git a/haystack/app.py b/archive/haystack/app.py similarity index 100% rename from haystack/app.py rename to archive/haystack/app.py diff --git a/haystack/chainlit.md b/archive/haystack/chainlit.md similarity index 100% rename from haystack/chainlit.md rename to archive/haystack/chainlit.md diff --git a/haystack/requirements.txt b/archive/haystack/requirements.txt similarity index 100% rename from haystack/requirements.txt rename to archive/haystack/requirements.txt diff --git a/langchain-ask-human/README.md b/archive/langchain-ask-human/README.md similarity index 100% rename from langchain-ask-human/README.md rename to archive/langchain-ask-human/README.md diff --git a/langchain-ask-human/app.py b/archive/langchain-ask-human/app.py similarity index 52% rename from langchain-ask-human/app.py rename to archive/langchain-ask-human/app.py index 353b1c794..49f686751 100644 --- a/langchain-ask-human/app.py +++ b/archive/langchain-ask-human/app.py @@ -1,60 +1,76 @@ from langchain.chains.llm_math.base import LLMMathChain from langchain.agents import initialize_agent, Tool, AgentType, AgentExecutor -from langchain_community.chat_models import ChatOpenAI +from langchain_openai import ChatOpenAI from typing import * from langchain.tools import BaseTool - +from langchain_core.runnables import RunnableConfig import chainlit as cl from chainlit.sync import run_sync +from typing import Optional + +from langchain_core.callbacks import ( + AsyncCallbackManagerForToolRun, + CallbackManagerForToolRun, +) +from langchain_core.tools import BaseTool +from langchain_core.tools.base import ArgsSchema +from pydantic import BaseModel, Field +from langgraph.prebuilt import create_react_agent + +class HumanInputSchema(BaseModel): + query: str = Field(description="The question to ask the human") + class HumanInputChainlit(BaseTool): """Tool that adds the capability to ask user for input.""" - name = "human" - description = ( + name: str = "human" + description: str = ( "You can ask a human for guidance when you think you " "got stuck or you are not sure what to do next. " "The input should be a question for the human." ) + args_schema: Optional[ArgsSchema] = HumanInputSchema + return_direct: bool = False def _run( self, query: str, - run_manager=None, + run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the Human input tool.""" - res = run_sync(cl.AskUserMessage(content=query).send()) return res["content"] + return "test" async def _arun( self, query: str, - run_manager=None, + run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Use the Human input tool.""" res = await cl.AskUserMessage(content=query).send() - return res["output"] - + return res["content"] + # return "test" @cl.on_chat_start def start(): - llm = ChatOpenAI(temperature=0, streaming=True, model_name="gpt-4-turbo-preview") + llm = ChatOpenAI(temperature=0, streaming=True, model_name="gpt-4o") llm_math_chain = LLMMathChain.from_llm(llm=llm, verbose=True) tools = [ HumanInputChainlit(), Tool( name="Calculator", - func=llm_math_chain.run, + func=llm_math_chain.invoke, description="useful for when you need to answer questions about math", - coroutine=llm_math_chain.arun, + coroutine=llm_math_chain.ainvoke, ), ] - agent = initialize_agent( - tools, llm, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True - ) + + + agent = create_react_agent(llm, tools=tools) cl.user_session.set("agent", agent) @@ -62,7 +78,10 @@ def start(): @cl.on_message async def main(message: cl.Message): agent = cl.user_session.get("agent") # type: AgentExecutor - res = await agent.arun( - message.content, callbacks=[cl.AsyncLangchainCallbackHandler()] + config = RunnableConfig(callbacks=[cl.AsyncLangchainCallbackHandler()]) + inputs = {"messages": [("user", message.content)]} + + res = await agent.ainvoke( + inputs, config=config ) - await cl.Message(content=res).send() + await cl.Message(content=res['messages'][-1].content).send() diff --git a/langchain-ask-human/ask-human.mp4 b/archive/langchain-ask-human/ask-human.mp4 similarity index 100% rename from langchain-ask-human/ask-human.mp4 rename to archive/langchain-ask-human/ask-human.mp4 diff --git a/langchain-ask-human/chainlit.md b/archive/langchain-ask-human/chainlit.md similarity index 100% rename from langchain-ask-human/chainlit.md rename to archive/langchain-ask-human/chainlit.md diff --git a/literal-langserve/README.md b/archive/literal-langserve/README.md similarity index 100% rename from literal-langserve/README.md rename to archive/literal-langserve/README.md diff --git a/literal-langserve/chainlit-app/.env.example b/archive/literal-langserve/chainlit-app/.env.example similarity index 100% rename from literal-langserve/chainlit-app/.env.example rename to archive/literal-langserve/chainlit-app/.env.example diff --git a/literal-langserve/chainlit-app/app.py b/archive/literal-langserve/chainlit-app/app.py similarity index 100% rename from literal-langserve/chainlit-app/app.py rename to archive/literal-langserve/chainlit-app/app.py diff --git a/literal-langserve/chainlit-app/chainlit.md b/archive/literal-langserve/chainlit-app/chainlit.md similarity index 100% rename from literal-langserve/chainlit-app/chainlit.md rename to archive/literal-langserve/chainlit-app/chainlit.md diff --git a/literal-langserve/images/chainlit_result.png b/archive/literal-langserve/images/chainlit_result.png similarity index 100% rename from literal-langserve/images/chainlit_result.png rename to archive/literal-langserve/images/chainlit_result.png diff --git a/literal-langserve/images/literal_result.png b/archive/literal-langserve/images/literal_result.png similarity index 100% rename from literal-langserve/images/literal_result.png rename to archive/literal-langserve/images/literal_result.png diff --git a/literal-langserve/langserve-app/.gitignore b/archive/literal-langserve/langserve-app/.gitignore similarity index 100% rename from literal-langserve/langserve-app/.gitignore rename to archive/literal-langserve/langserve-app/.gitignore diff --git a/literal-langserve/langserve-app/Dockerfile b/archive/literal-langserve/langserve-app/Dockerfile similarity index 100% rename from literal-langserve/langserve-app/Dockerfile rename to archive/literal-langserve/langserve-app/Dockerfile diff --git a/literal-langserve/langserve-app/README.md b/archive/literal-langserve/langserve-app/README.md similarity index 100% rename from literal-langserve/langserve-app/README.md rename to archive/literal-langserve/langserve-app/README.md diff --git a/literal-langserve/langserve-app/app/.env.example b/archive/literal-langserve/langserve-app/app/.env.example similarity index 100% rename from literal-langserve/langserve-app/app/.env.example rename to archive/literal-langserve/langserve-app/app/.env.example diff --git a/literal-langserve/langserve-app/app/__init__.py b/archive/literal-langserve/langserve-app/app/__init__.py similarity index 100% rename from literal-langserve/langserve-app/app/__init__.py rename to archive/literal-langserve/langserve-app/app/__init__.py diff --git a/literal-langserve/langserve-app/app/server.py b/archive/literal-langserve/langserve-app/app/server.py similarity index 100% rename from literal-langserve/langserve-app/app/server.py rename to archive/literal-langserve/langserve-app/app/server.py diff --git a/literal-langserve/langserve-app/packages/README.md b/archive/literal-langserve/langserve-app/packages/README.md similarity index 100% rename from literal-langserve/langserve-app/packages/README.md rename to archive/literal-langserve/langserve-app/packages/README.md diff --git a/literal-langserve/langserve-app/pyproject.toml b/archive/literal-langserve/langserve-app/pyproject.toml similarity index 100% rename from literal-langserve/langserve-app/pyproject.toml rename to archive/literal-langserve/langserve-app/pyproject.toml diff --git a/openai-functions-codeinterpreter/.env.example b/archive/openai-functions-codeinterpreter/.env.example similarity index 100% rename from openai-functions-codeinterpreter/.env.example rename to archive/openai-functions-codeinterpreter/.env.example diff --git a/openai-functions-codeinterpreter/README.md b/archive/openai-functions-codeinterpreter/README.md similarity index 100% rename from openai-functions-codeinterpreter/README.md rename to archive/openai-functions-codeinterpreter/README.md diff --git a/openai-functions-codeinterpreter/app.py b/archive/openai-functions-codeinterpreter/app.py similarity index 99% rename from openai-functions-codeinterpreter/app.py rename to archive/openai-functions-codeinterpreter/app.py index 8238c548c..9dbb32573 100644 --- a/openai-functions-codeinterpreter/app.py +++ b/archive/openai-functions-codeinterpreter/app.py @@ -108,7 +108,7 @@ async def on_message(message: cl.Message): stream_resp = None send_message = __truncate_conversation(message_history) try: - stream = openai_client.chat.completions.create( + stream = await openai_client.chat.completions.create( model="gpt-4", messages=send_message, stream=True, diff --git a/openai-functions-codeinterpreter/chainlit.md b/archive/openai-functions-codeinterpreter/chainlit.md similarity index 100% rename from openai-functions-codeinterpreter/chainlit.md rename to archive/openai-functions-codeinterpreter/chainlit.md diff --git a/openai-functions-codeinterpreter/functions/FunctionManager.py b/archive/openai-functions-codeinterpreter/functions/FunctionManager.py similarity index 100% rename from openai-functions-codeinterpreter/functions/FunctionManager.py rename to archive/openai-functions-codeinterpreter/functions/FunctionManager.py diff --git a/openai-functions-codeinterpreter/functions/__init__.py b/archive/openai-functions-codeinterpreter/functions/__init__.py similarity index 100% rename from openai-functions-codeinterpreter/functions/__init__.py rename to archive/openai-functions-codeinterpreter/functions/__init__.py diff --git a/openai-functions-codeinterpreter/plugins/common/config.json b/archive/openai-functions-codeinterpreter/plugins/common/config.json similarity index 100% rename from openai-functions-codeinterpreter/plugins/common/config.json rename to archive/openai-functions-codeinterpreter/plugins/common/config.json diff --git a/openai-functions-codeinterpreter/plugins/common/functions.py b/archive/openai-functions-codeinterpreter/plugins/common/functions.py similarity index 100% rename from openai-functions-codeinterpreter/plugins/common/functions.py rename to archive/openai-functions-codeinterpreter/plugins/common/functions.py diff --git a/openai-functions-codeinterpreter/plugins/python/config.json b/archive/openai-functions-codeinterpreter/plugins/python/config.json similarity index 100% rename from openai-functions-codeinterpreter/plugins/python/config.json rename to archive/openai-functions-codeinterpreter/plugins/python/config.json diff --git a/openai-functions-codeinterpreter/plugins/python/executor.py b/archive/openai-functions-codeinterpreter/plugins/python/executor.py similarity index 100% rename from openai-functions-codeinterpreter/plugins/python/executor.py rename to archive/openai-functions-codeinterpreter/plugins/python/executor.py diff --git a/openai-functions-codeinterpreter/plugins/python/functions.py b/archive/openai-functions-codeinterpreter/plugins/python/functions.py similarity index 100% rename from openai-functions-codeinterpreter/plugins/python/functions.py rename to archive/openai-functions-codeinterpreter/plugins/python/functions.py diff --git a/openai-functions-codeinterpreter/plugins/vue/config.json b/archive/openai-functions-codeinterpreter/plugins/vue/config.json similarity index 100% rename from openai-functions-codeinterpreter/plugins/vue/config.json rename to archive/openai-functions-codeinterpreter/plugins/vue/config.json diff --git a/openai-functions-codeinterpreter/plugins/vue/functions.py b/archive/openai-functions-codeinterpreter/plugins/vue/functions.py similarity index 100% rename from openai-functions-codeinterpreter/plugins/vue/functions.py rename to archive/openai-functions-codeinterpreter/plugins/vue/functions.py diff --git a/openai-functions-codeinterpreter/requirements.txt b/archive/openai-functions-codeinterpreter/requirements.txt similarity index 100% rename from openai-functions-codeinterpreter/requirements.txt rename to archive/openai-functions-codeinterpreter/requirements.txt diff --git a/openai-functions/.env.example b/archive/openai-functions/.env.example similarity index 100% rename from openai-functions/.env.example rename to archive/openai-functions/.env.example diff --git a/openai-functions/README.md b/archive/openai-functions/README.md similarity index 100% rename from openai-functions/README.md rename to archive/openai-functions/README.md diff --git a/openai-functions/app.py b/archive/openai-functions/app.py similarity index 100% rename from openai-functions/app.py rename to archive/openai-functions/app.py diff --git a/openai-functions/chainlit.md b/archive/openai-functions/chainlit.md similarity index 100% rename from openai-functions/chainlit.md rename to archive/openai-functions/chainlit.md diff --git a/openai-functions/rendering.png b/archive/openai-functions/rendering.png similarity index 100% rename from openai-functions/rendering.png rename to archive/openai-functions/rendering.png diff --git a/llama-index/app.py b/llama-index/app.py index 886f9961e..b9a6efda4 100644 --- a/llama-index/app.py +++ b/llama-index/app.py @@ -36,9 +36,9 @@ async def start(): Settings.embed_model = OpenAIEmbedding(model="text-embedding-3-small") Settings.context_window = 4096 - service_context = ServiceContext.from_defaults( - callback_manager=CallbackManager([cl.LlamaIndexCallbackHandler()]) - ) + Settings.callback_manager = CallbackManager([cl.LlamaIndexCallbackHandler()]) + service_context = Settings.callback_manager + query_engine = index.as_query_engine( streaming=True, similarity_top_k=2, service_context=service_context ) diff --git a/loader-animation/app.py b/loader-animation/app.py index dffd0593c..002d56fe5 100644 --- a/loader-animation/app.py +++ b/loader-animation/app.py @@ -10,7 +10,7 @@ async def send_animated_message( base_msg: str, frames: List[str], interval: float = 0.8 -) -> None: + ) -> None: """Display animated message with minimal resource usage""" msg = cl.Message(content=base_msg) await msg.send() @@ -24,8 +24,9 @@ async def send_animated_message( current_frame = frames[progress % len(frames)] progress_bar = ("▣" * (progress % bar_length)).ljust(bar_length, "▢") - # Single update operation - msg.content = f"{current_frame} {base_msg}\n{progress_bar}" + # Single update operation - overwrite entire content + new_content = f"{current_frame} {base_msg}\n{progress_bar}" + msg.content = new_content await msg.update() progress += 1 @@ -33,30 +34,6 @@ async def send_animated_message( except asyncio.CancelledError: msg.content = base_msg await msg.update() # Final static message - base_msg: str, - frames: List[str], - interval: float = 0.8 -) -> None: - """Display animated message with minimal resource usage""" - msg = cl.Message(content=base_msg) - await msg.send() - - progress = 0 - bar_length = 12 # Optimal length for progress bar - - try: - while True: - # Efficient progress calculation - current_frame = frames[progress % len(frames)] - progress_bar = ("▣" * (progress % bar_length)).ljust(bar_length, "▢") - - # Single update operation - await msg.update(content=f"{current_frame} {base_msg}\n{progress_bar}") - - progress += 1 - await asyncio.sleep(interval) - except asyncio.CancelledError: - await msg.update(content=base_msg) # Final static message @cl.on_message async def main(message: cl.Message) -> None: diff --git a/reflection-70b/chainlit.md b/loader-animation/chainlit.md similarity index 100% rename from reflection-70b/chainlit.md rename to loader-animation/chainlit.md diff --git a/mcp-linear/app.py b/mcp-linear/app.py index 944732610..18718aa0f 100644 --- a/mcp-linear/app.py +++ b/mcp-linear/app.py @@ -55,15 +55,22 @@ def flatten(xss): @cl.on_mcp_connect async def on_mcp(connection, session: ClientSession): result = await session.list_tools() - tools = [ - { - "name": t.name, - "description": t.description, - "input_schema": t.inputSchema, - } - for t in result.tools - ] - + tools = [{ + "name": t.name, + "description": t.description, + "input_schema": t.inputSchema, + } for t in result.tools] + + # Save tools to a JSON file + import os + + # Create directory if it doesn't exist + os.makedirs("tools_data", exist_ok=True) + + # Save to JSON file + with open(f"tools_data/{connection.name}_tools.json", "w") as f: + json.dump(tools, f, indent=2) + mcp_tools = cl.user_session.get("mcp_tools", {}) mcp_tools[connection.name] = tools cl.user_session.set("mcp_tools", mcp_tools) diff --git a/mcp-linear/tools_data/Linear_tools.json b/mcp-linear/tools_data/Linear_tools.json new file mode 100644 index 000000000..4295e467e --- /dev/null +++ b/mcp-linear/tools_data/Linear_tools.json @@ -0,0 +1,168 @@ +[ + { + "name": "create_issue", + "description": "Create a new issue in Linear", + "input_schema": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "Issue title" + }, + "description": { + "type": "string", + "description": "Issue description (markdown supported)" + }, + "teamId": { + "type": "string", + "description": "Team ID" + }, + "assigneeId": { + "type": "string", + "description": "Assignee user ID (optional)" + }, + "priority": { + "type": "number", + "description": "Priority (0-4, optional)", + "minimum": 0, + "maximum": 4 + }, + "labels": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Label IDs to apply (optional)" + } + }, + "required": [ + "title", + "teamId" + ] + } + }, + { + "name": "list_issues", + "description": "List issues with optional filters", + "input_schema": { + "type": "object", + "properties": { + "teamId": { + "type": "string", + "description": "Filter by team ID (optional)" + }, + "assigneeId": { + "type": "string", + "description": "Filter by assignee ID (optional)" + }, + "status": { + "type": "string", + "description": "Filter by status (optional)" + }, + "first": { + "type": "number", + "description": "Number of issues to return (default: 50)" + } + } + } + }, + { + "name": "update_issue", + "description": "Update an existing issue", + "input_schema": { + "type": "object", + "properties": { + "issueId": { + "type": "string", + "description": "Issue ID" + }, + "title": { + "type": "string", + "description": "New title (optional)" + }, + "description": { + "type": "string", + "description": "New description (optional)" + }, + "status": { + "type": "string", + "description": "New status (optional)" + }, + "assigneeId": { + "type": "string", + "description": "New assignee ID (optional)" + }, + "priority": { + "type": "number", + "description": "New priority (0-4, optional)", + "minimum": 0, + "maximum": 4 + } + }, + "required": [ + "issueId" + ] + } + }, + { + "name": "list_teams", + "description": "List all teams in the workspace", + "input_schema": { + "type": "object", + "properties": {} + } + }, + { + "name": "list_projects", + "description": "List all projects", + "input_schema": { + "type": "object", + "properties": { + "teamId": { + "type": "string", + "description": "Filter by team ID (optional)" + }, + "first": { + "type": "number", + "description": "Number of projects to return (default: 50)" + } + } + } + }, + { + "name": "search_issues", + "description": "Search for issues using a text query", + "input_schema": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "Search query text" + }, + "first": { + "type": "number", + "description": "Number of results to return (default: 50)" + } + }, + "required": [ + "query" + ] + } + }, + { + "name": "get_issue", + "description": "Get detailed information about a specific issue", + "input_schema": { + "type": "object", + "properties": { + "issueId": { + "type": "string", + "description": "Issue ID" + } + }, + "required": [ + "issueId" + ] + } + } +] \ No newline at end of file diff --git a/mcp/app.py b/mcp/app.py index 94e01fcec..3d9cf533d 100644 --- a/mcp/app.py +++ b/mcp/app.py @@ -5,8 +5,37 @@ import chainlit as cl +import os +from dotenv import load_dotenv + +# Load environment variables from .env file +load_dotenv() + anthropic_client = anthropic.AsyncAnthropic() -SYSTEM = "you are a helpful assistant." +SYSTEM = "You are a helpful assistant. You are a member of a team that uses Linear to manage their projects. Once you've diplayed a ticket, do not mention it again in your response - JUST SAY `here is the ticket information!`" +regular_tools = [{ + "name": "show_linear_ticket", + "description": "Displays a Linear ticket in the UI with its details. Use this tool after retrieving ticket information to show a visual representation of the ticket. The tool will create a card showing the ticket title, status, assignee, deadline, and tags. This provides a cleaner presentation than text-only responses.", + "input_schema": { + "type": "object", + "properties": {"title": {"type": "string"}, "status": {"type": "string"}, "assignee": {"type": "string"}, "deadline": {"type": "string"}, "tags": {"type": "array", "items": {"type": "string"}}}, + "required": ["title", "status", "assignee", "deadline", "tags"] + } +}] + +async def show_linear_ticket(title, status, assignee, deadline, tags): + props = { + "title": title, + "status": status, + "assignee": assignee, + "deadline": deadline, + "tags": tags + } + print("props", props) + ticket_element = cl.CustomElement(name="LinearTicket", props=props) + await cl.Message(content="", elements=[ticket_element], author="show_linear_ticket").send() + return "the ticket was displayed to the user: " + str(props) + def flatten(xss): return [x for xs in xss for x in xs] @@ -36,7 +65,7 @@ async def call_tool(tool_use): # Identify which mcp is used mcp_tools = cl.user_session.get("mcp_tools", {}) mcp_name = None - + for connection_name, tools in mcp_tools.items(): if any(tool.get("name") == tool_name for tool in tools): mcp_name = connection_name @@ -62,9 +91,10 @@ async def call_tool(tool_use): async def call_claude(chat_messages): msg = cl.Message(content="") mcp_tools = cl.user_session.get("mcp_tools", {}) + regular_tools = cl.user_session.get("regular_tools", []) # Flatten the tools from all MCP connections - tools = flatten([tools for _, tools in mcp_tools.items()]) - + tools = flatten([tools for _, tools in mcp_tools.items()]) + regular_tools + print([tool.get("name") for tool in tools]) async with anthropic_client.messages.stream( system=SYSTEM, max_tokens=1024, @@ -83,6 +113,8 @@ async def call_claude(chat_messages): @cl.on_chat_start async def start_chat(): cl.user_session.set("chat_messages", []) + cl.user_session.set("regular_tools", regular_tools) + @cl.on_message async def on_message(msg: cl.Message): @@ -92,7 +124,10 @@ async def on_message(msg: cl.Message): while response.stop_reason == "tool_use": tool_use = next(block for block in response.content if block.type == "tool_use") - tool_result = await call_tool(tool_use) + if tool_use.name == "show_linear_ticket": + tool_result = await show_linear_ticket(**tool_use.input) + else: + tool_result = await call_tool(tool_use) messages = [ {"role": "assistant", "content": response.content}, diff --git a/mcp/public/avatars/get_issue.svg b/mcp/public/avatars/get_issue.svg new file mode 100644 index 000000000..2df799e3f --- /dev/null +++ b/mcp/public/avatars/get_issue.svg @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/mcp/public/avatars/list_issues.svg b/mcp/public/avatars/list_issues.svg new file mode 100644 index 000000000..2df799e3f --- /dev/null +++ b/mcp/public/avatars/list_issues.svg @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/mcp/public/avatars/show_linear_ticket.svg b/mcp/public/avatars/show_linear_ticket.svg new file mode 100644 index 000000000..2df799e3f --- /dev/null +++ b/mcp/public/avatars/show_linear_ticket.svg @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/mcp/public/elements/LinearTicket.jsx b/mcp/public/elements/LinearTicket.jsx new file mode 100644 index 000000000..873368e3e --- /dev/null +++ b/mcp/public/elements/LinearTicket.jsx @@ -0,0 +1,53 @@ +import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card" +import { Badge } from "@/components/ui/badge" +import { Progress } from "@/components/ui/progress" +import { Clock, User, Tag } from "lucide-react" + +export default function TicketStatusCard() { + const getProgressValue = (status) => { + const progress = { + 'open': 25, + 'In Progress': 50, + 'resolved': 75, + 'closed': 100 + } + return progress[status] || 0 + } + + return ( + + +
+ + {props.title || 'Untitled Ticket'} + + + {props.status || 'Unknown'} + +
+
+ +
+ + +
+
+ + {props.assignee || 'Unassigned'} +
+
+ + {props.deadline || 'No deadline'} +
+
+ + {props.tags?.join(', ') || 'No tags'} +
+
+
+
+
+ ) +} \ No newline at end of file diff --git a/openai-concurrent-functions/app.py b/openai-concurrent-functions/app.py index 56fe74e15..0cb227f20 100644 --- a/openai-concurrent-functions/app.py +++ b/openai-concurrent-functions/app.py @@ -62,19 +62,19 @@ async def run_conversation(message: cl.Message): message_history.append({"role": "user", "content": message.content}) # Step 1: send the conversation and available functions to the model - msg = cl.Message(author="Assistant", content="") - await msg.send() + response = await client.chat.completions.create( - model="gpt-3.5-turbo-1106", + model="gpt-4o-mini", messages=message_history, tools=tools, tool_choice="auto", # auto is default, but we'll be explicit ) response_message = response.choices[0].message - msg.content = response_message.content or "" - await msg.update() + if response_message.content: + msg = cl.Message(author="Assistant", content=response_message.content) + await msg.send() tool_calls = response_message.tool_calls # Step 2: check if the model wanted to call a function @@ -112,7 +112,7 @@ async def call_function(tool_call): # Extend conversation with all function responses message_history.extend(function_responses) second_response = await client.chat.completions.create( - model="gpt-3.5-turbo-1106", + model="gpt-4o-mini", messages=message_history, ) # get a new response from the model where it can see the function response second_message = second_response.choices[0].message diff --git a/openai-concurrent-streaming/app.py b/openai-concurrent-streaming/app.py index 49ed37a30..13fa97c95 100644 --- a/openai-concurrent-streaming/app.py +++ b/openai-concurrent-streaming/app.py @@ -7,7 +7,7 @@ openai_client = AsyncClient(api_key=os.environ.get("OPENAI_API_KEY")) -model_name = "gpt-3.5-turbo" +model_name = "gpt-4o-mini" settings = { "temperature": 0.3, "max_tokens": 500, diff --git a/openinterpreter/.env.example b/openinterpreter/.env.example deleted file mode 100644 index 9847a1df1..000000000 --- a/openinterpreter/.env.example +++ /dev/null @@ -1 +0,0 @@ -OPENAI_API_KEY= \ No newline at end of file diff --git a/openinterpreter/README.md b/openinterpreter/README.md deleted file mode 100644 index 3e060a463..000000000 --- a/openinterpreter/README.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: 'OpenInterpreter x Chainlit' -tags: ['openinterpreter', 'chainlit'] ---- - -# Welcome to OpenInterpreter x Chainlit! 🚀🤖 - -**OpenInterpreter**: https://github.com/KillianLucas/open-interpreter/ - -**Chainlit**: https://github.com/chainlit/chainlit - -Open Interpreter lets LLMs run code (Python, Javascript, Shell, and more) locally. You can chat with Open Interpreter through a ChatGPT-like interface in your terminal by running $ interpreter after installing. - - -This Chainlit cookbook example allows you to do just that from a web app, with additional UI features such as file uploads, downloads, Images and other UI Elements. - -This is an example combining both to provide a code interpreter-like app. - -## High-Level Description - -The integration allows users to: -1. Select an LLM of their choice. -2. Optionally upload files to be used by the LLM. -3. Interact with the LLM through a chat interface, sending and receiving messages that can include code execution requests. - -## Quickstart - -To get started with this integration, follow these steps: - -1. **Install OpenInterpreter**: Follow the installation instructions on the [OpenInterpreter GitHub page](https://github.com/KillianLucas/open-interpreter/). - -2. **Install Chainlit**: Chainlit can be installed via pip: -```shell -pip install chainlit -``` - -3. **Set Up Environment Variables**: Ensure that your OpenAI API key is set as an environment variable: -```shell -export OPENAI_API_KEY='your_api_key_here' -``` - -4. **Run the Application**: Navigate to the directory containing the `app.py` file and run: -```shell -chainlit run app.py -``` - -5. **Interact with the Web App**: Open your web browser to the address provided by Chainlit (usually `http://localhost:8501`) and start interacting with the application. - -## Code Definitions - -- `CustomStdout`: A class that overrides the standard output to redirect print statements to the Chainlit UI. -- `CustomStdin`: A class that overrides the standard input to receive input from the Chainlit UI. -- `@cl.on_chat_start`: A decorator that initializes the custom standard input/output classes and sets up the chat settings. -- `@cl.on_settings_update`: A decorator that updates the selected LLM model based on user input. -- `@cl.on_message`: A decorator that handles incoming messages, processes file uploads, and interacts with the OpenInterpreter. - -[Demo](openinterpreter/openinterpreter-chainlit.mp4) - ---- - -Enjoy the power of LLMs in your browser with OpenInterpreter x Chainlit! \ No newline at end of file diff --git a/openinterpreter/app.py b/openinterpreter/app.py deleted file mode 100644 index ef8e29b56..000000000 --- a/openinterpreter/app.py +++ /dev/null @@ -1,85 +0,0 @@ -import interpreter -import chainlit as cl -from chainlit.input_widget import Select - -import sys, os - -interpreter.api_key = os.getenv("OPENAI_API_KEY") -# interpreter.debug_mode=True - - -# 1. Custom StdOut class to output prints to Chainlit UI -# 2. Custom StdIn class to receive input from Chainlit UI -# WARNING: Do not write prints in there, otherwise infinite loop -class CustomStdout: - def __init__(self, original_stdout): - self.original_stdout = original_stdout - - def write(self, data): - # React to the data being written. For this example, I'm just printing to stderr. - # language = "" - # if interpreter.active_block and type(interpreter.active_block).__name__ == "CodeBlock": - # if interpreter.active_block.language: - # language = interpreter.active_block.language - if data != "\n" and data != "": - # cl.run_sync(cl.Message(content=data, language=language).send()) - cl.run_sync(cl.Message(content=data).send()) - # Write the data to the original stdout (so it still gets displayed) - self.original_stdout.write(data) - - def flush(self): - # If needed, you can also implement flush - self.original_stdout.flush() - - -class CustomStdin: - def __init__(self, original_stdin): - self.original_stdin = original_stdin - - def readline(self): - response_from_ui = cl.run_sync(cl.AskUserMessage(content="").send()) - return str(response_from_ui["content"]) - - def flush(self): - self.original_stdin.flush() - - -@cl.on_chat_start -async def start(): - sys.stdout = CustomStdout(sys.__stdout__) - sys.stdin = CustomStdin(sys.__stdin__) - settings = await cl.ChatSettings( - [ - Select( - id="model", - label="OpenAI - Model", - values=["gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4", "gpt-4-32k"], - initial_index=0, - ), - ] - ).send() - interpreter.model = settings["model"] - - -@cl.on_settings_update -async def setup_agent(settings): - interpreter.model = settings["model"] - await cl.Message(content=f"Chose OpenAI model {settings['model']}").send() - - -@cl.on_message -async def main(message: cl.Message): - if message.elements: - for element in message.elements: - file_name = element.name - content = element.content - # If want to show content Content: {content.decode('utf-8')}\n\n - await cl.Message(content=f"Uploaded file: {file_name}\n").send() - - # Save the file locally - with open(file_name, "wb") as file: - file.write(content) - interpreter.load( - [{"role": "assistant", "content": f"User uploaded file: {file_name}"}] - ) - interpreter.chat(message.content) diff --git a/openinterpreter/chainlit.md b/openinterpreter/chainlit.md deleted file mode 100644 index 4a2a07342..000000000 --- a/openinterpreter/chainlit.md +++ /dev/null @@ -1,56 +0,0 @@ -# Welcome to OpenInterpreter x Chainlit! 🚀🤖 - -**OpenInterpreter**: https://github.com/KillianLucas/open-interpreter/ - -**Chainlit**: https://github.com/chainlit/chainlit - -Open Interpreter lets LLMs run code (Python, Javascript, Shell, and more) locally. You can chat with Open Interpreter through a ChatGPT-like interface in your terminal by running $ interpreter after installing. - - -This Chainlit cookbook example allows you to do just that from a web app, with additional UI features such as file uploads, downloads, Images and other UI Elements. - -This is an example combining both to provide a code interpreter-like app. - -## High-Level Description - -The integration allows users to: -1. Select an LLM of their choice. -2. Optionally upload files to be used by the LLM. -3. Interact with the LLM through a chat interface, sending and receiving messages that can include code execution requests. - -## Quickstart - -To get started with this integration, follow these steps: - -1. **Install OpenInterpreter**: Follow the installation instructions on the [OpenInterpreter GitHub page](https://github.com/KillianLucas/open-interpreter/). - -2. **Install Chainlit**: Chainlit can be installed via pip: -```shell -pip install chainlit -``` - -3. **Set Up Environment Variables**: Ensure that your OpenAI API key is set as an environment variable: -```shell -export OPENAI_API_KEY='your_api_key_here' -``` - -4. **Run the Application**: Navigate to the directory containing the `app.py` file and run: -```shell -chainlit run app.py -``` - -5. **Interact with the Web App**: Open your web browser to the address provided by Chainlit (usually `http://localhost:8501`) and start interacting with the application. - -## Code Definitions - -- `CustomStdout`: A class that overrides the standard output to redirect print statements to the Chainlit UI. -- `CustomStdin`: A class that overrides the standard input to receive input from the Chainlit UI. -- `@cl.on_chat_start`: A decorator that initializes the custom standard input/output classes and sets up the chat settings. -- `@cl.on_settings_update`: A decorator that updates the selected LLM model based on user input. -- `@cl.on_message`: A decorator that handles incoming messages, processes file uploads, and interacts with the OpenInterpreter. - -[Demo](openinterpreter/openinterpreter-chainlit.mp4) - ---- - -Enjoy the power of LLMs in your browser with OpenInterpreter x Chainlit! \ No newline at end of file diff --git a/openinterpreter/openinterpreter-chainlit.mp4 b/openinterpreter/openinterpreter-chainlit.mp4 deleted file mode 100644 index b51a0dd55..000000000 Binary files a/openinterpreter/openinterpreter-chainlit.mp4 and /dev/null differ diff --git a/reflection-70b/app.py b/reflection-70b/app.py deleted file mode 100644 index 020bba0c6..000000000 --- a/reflection-70b/app.py +++ /dev/null @@ -1,97 +0,0 @@ -import requests -import os -import chainlit as cl -from dotenv import load_dotenv - -# Load environment variables from .env file -load_dotenv() - - -def call_model(messages): - # Model ID for production deployment - model_id = os.getenv("MODEL_ID") - # Read secrets from environment variables - baseten_api_key = os.getenv("BASETEN_API_KEY") - # Call model endpoint - resp = requests.post( - f"https://model-{model_id}.api.baseten.co/production/predict", - headers={"Authorization": f"Api-Key {baseten_api_key}"}, - json={"messages": messages, "max_tokens": 1024, "temperature": 0.7}, - stream=True, - ) - - # Stream the generated tokens - for content in resp.iter_content(): - yield content.decode("utf-8") - - -@cl.set_starters -async def set_starters(): - return [ - cl.Starter( - label="Reflection-70B", message="how many R's are there in Strawberry?" - ) - ] - - -@cl.on_chat_start -def init_history(): - system_prompt = "You are a world-class AI system, capable of complex reasoning and reflection. Reason through the query inside tags, and then provide your final response inside tags. If you detect that you made a mistake in your reasoning at any point, correct yourself inside tags." - - message_history = [{"role": "system", "content": system_prompt}] - cl.user_session.set("history", message_history) - - -@cl.on_message -async def main(message: cl.Message): - # Get the current message history - message_history = cl.user_session.get("history") - - # Add the user's message to the history - message_history.append({"role": "user", "content": message.content}) - - # RAW - # msg = cl.Message(content="") - # # option 1 - # for chunk in call_model(message_history): - # if chunk: - # await msg.stream_token(chunk) - # msg.send() - # # Add the assistant's response to the history - # message_history.append({"role": "assistant", "content": msg.content}) - - raw_answer = "" - is_thinking = False - is_answering = False - - # Todo: fix when answer is just <|start_header_id|>assistant<|end_header_id|>\n\n SOMETHING <|eot_id|> - for chunk in call_model(message_history): - raw_answer += chunk - if raw_answer.endswith(""): - is_thinking = True - msg = cl.Message(author="Thinking", content="") - await msg.send() - elif raw_answer.endswith(""): - await msg.stream_token(chunk) - is_thinking = False - await msg.update() - elif raw_answer.endswith(""): - is_answering = True - msg = cl.Message(author="Answer", content="") - await msg.send() - elif raw_answer.endswith(""): - await msg.stream_token(chunk) - is_answering = False - await msg.update() - if chunk and (is_thinking or is_answering): - await msg.stream_token(chunk) - - raw_answer = raw_answer.replace( - "<|start_header_id|>assistant<|end_header_id|>\n\n", "" - ) - raw_answer = raw_answer.replace("<|eot_id|>", "") - - message_history.append({"role": "assistant", "content": raw_answer}) - - # Update the session history - cl.user_session.set("history", message_history) diff --git a/reflection-70b/llama-3-1-8b-trt-llm/config.yaml b/reflection-70b/llama-3-1-8b-trt-llm/config.yaml deleted file mode 100644 index 545a04cf1..000000000 --- a/reflection-70b/llama-3-1-8b-trt-llm/config.yaml +++ /dev/null @@ -1,28 +0,0 @@ -build_commands: [] -environment_variables: {} -external_package_dirs: [] -model_metadata: {} -model_name: Reflection 70B -python_version: py39 -requirements: [] -resources: - accelerator: A100:4 - cpu: '1' - memory: 24Gi - use_gpu: true -secrets: - hf_access_token: set token in baseten workspace -system_packages: [] -trt_llm: - build: - base_model: llama - checkpoint_repository: - repo: mattshumer/Reflection-Llama-3.1-70B - source: HF - max_batch_size: 32 - max_beam_width: 1 - max_input_len: 7168 - max_output_len: 1024 # 4096 - num_builder_gpus: 4 - quantization_type: no_quant - tensor_parallel_count: 4 diff --git a/reflection-70b/llama-3-1-8b-trt-llm/model/__init__.py b/reflection-70b/llama-3-1-8b-trt-llm/model/__init__.py deleted file mode 100644 index e69de29bb..000000000