-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
• Implemented minor adjustments to enhance Langchain compatibility. • Increased example quantity for improved functionality identification. • Updated tool detection handling; "content" is now set to an empty string, as opposed to "None" due to Langchain library. • Introduced a "groqchain" endpoint. • Provided an additional example.
- Loading branch information
Showing
8 changed files
with
272 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# To be developed | ||
EVALUATION_CYCLES_COUNT=3 | ||
EVALUATION_CYCLES_COUNT=1 | ||
PARSE_ERROR_TRIES = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# pip install --upgrade --quiet langchain-groq tavily-python langchain langchainhub langchain-openai | ||
|
||
from langchain_core.prompts import ChatPromptTemplate | ||
from langchain_groq import ChatGroq | ||
import os | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
from langchain import hub | ||
from langchain.agents import create_openai_tools_agent | ||
from langchain_community.tools.tavily_search import TavilySearchResults, TavilyAnswer | ||
from langchain.agents import AgentExecutor | ||
|
||
# The following code raise an error. | ||
chat = ChatGroq( | ||
temperature=0, | ||
groq_api_key=os.environ["GROQ_API_KEY"], | ||
model_name="mixtral-8x7b-32768", | ||
) | ||
|
||
prompt = hub.pull("hwchase17/openai-tools-agent") | ||
tools = [TavilySearchResults(max_results=1)] | ||
agent = create_openai_tools_agent(chat, tools, prompt) | ||
|
||
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, stream_runnable = False) | ||
agent_executor.invoke({"input": "What is Langchain?"}) | ||
|
||
|
||
# The following code works fine using GroqCall (Funckycall) proxy | ||
chat = ChatGroq( | ||
temperature=0, | ||
groq_api_key=os.environ["GROQ_API_KEY"], | ||
model_name="mixtral-8x7b-32768", | ||
groq_api_base= "http://localhost:8000/proxy/groqchain" | ||
# groq_api_base= "http://groqcall.ai/proxy/groqchain" | ||
) | ||
|
||
# Example 1: Chat with tools | ||
prompt = hub.pull("hwchase17/openai-tools-agent") | ||
tools = [TavilySearchResults(max_results=1)] | ||
agent = create_openai_tools_agent(chat, tools, prompt) | ||
|
||
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, stream_runnable = False) | ||
result = agent_executor.invoke({"input": "What is Langchain?"}) | ||
print(result) | ||
|
||
# Example 1: Simple chat | ||
system = "You are a helpful assistant." | ||
human = "{text}" | ||
prompt = ChatPromptTemplate.from_messages([("system", system), ("human", human)]) | ||
|
||
chain = prompt | chat | ||
result = chain.invoke({"text": "Explain the importance of low latency LLMs."}) | ||
print(result) |