id stringlengths 14 16 | text stringlengths 36 2.73k | source stringlengths 49 117 |
|---|---|---|
a93f150bed4a-3 | Speak directly to {character_name}.
Do not add anything else."""
)
]
character_description = ChatOpenAI(temperature=1.0)(character_specifier_prompt).content
return character_description
def generate_character_header(character_name, character_description):
return f"""{game_descrip... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-4 | for character_name, character_description, character_header, character_system_message in zip(character_names, character_descriptions, character_headers, character_system_messages):
print(f'\n\n{character_name} Description:')
print(f'\n{character_description}')
print(f'\n{character_header}')
print(f'\n{c... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-5 | Your goal is to be as creative as possible and make the voters think you are the best candidate.
You will speak in the style of Donald Trump, and exaggerate their personality.
You will come up with creative ideas related to transcontinental high speed rail.
Do not say the same things over and over again.
Speak in the f... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-6 | Your name is Kanye West.
You are a presidential candidate.
Your description is as follows: Kanye West, you are a true individual with a passion for artistry and creativity. You are known for your bold ideas and willingness to take risks. Your determination to break barriers and push boundaries makes you a charismatic a... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-7 | Here is the topic for the presidential debate: transcontinental high speed rail.
The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.
Your name is Elizabeth Warren.
You are a presidential candidate.
Your description is as follows: Senator Warren, you are a fearless leader who fights for the litt... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-8 | output_keys=['bid'],
default_output_key='bid')
Generate bidding system message#
This is inspired by the prompt used in Generative Agents for using an LLM to determine the importance of memories. This will use the formatting instructions from our BidOutputParser.
def generate_character_bidding_template(character_hea... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-9 | ```
{recent_message}
```
Your response should be an integer delimited by angled brackets, like this: <int>.
Do nothing else.
Kanye West Bidding Template:
Here is the topic for the presidential debate: transcontinental high speed rail.
The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.
You... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-10 | ```
{message_history}
```
On the scale of 1 to 10, where 1 is not contradictory and 10 is extremely contradictory, rate how contradictory the following message is to your ideas.
```
{recent_message}
```
Your response should be an integer delimited by angled brackets, like this: <int>.
Do nothing else.
Use an LLM t... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-11 | We will define a ask_for_bid function that uses the bid_parser we defined before to parse the agent’s bid. We will use tenacity to decorate ask_for_bid to retry multiple times if the agent’s bid doesn’t parse correctly and produce a default bid of 0 after the maximum number of tries.
@tenacity.retry(stop=tenacity.stop_... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-12 | print('\n')
return idx
Main Loop#
characters = []
for character_name, character_system_message, bidding_template in zip(character_names, character_system_messages, character_bidding_templates):
characters.append(BiddingDialogueAgent(
name=character_name,
system_message=character_system_message,
... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-13 | Bids:
Donald Trump bid: 2
Kanye West bid: 8
Elizabeth Warren bid: 10
Selected: Elizabeth Warren
(Elizabeth Warren): Thank you for the question. As a fearless leader who fights for the little guy, I believe that building a sustainable and inclusive transcontinental high-speed rail is not only necessary for our econom... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-14 | Bids:
Donald Trump bid: 7
Kanye West bid: 1
Elizabeth Warren bid: 1
Selected: Donald Trump
(Donald Trump): Kanye, you're a great artist, but this is about practicality. Solar power is too expensive and unreliable. We need to focus on what works, and that's clean coal. And as for the design, we'll make it beautiful, ... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-15 | Kanye West bid: 8
Elizabeth Warren bid: 10
Selected: Elizabeth Warren
(Elizabeth Warren): Thank you, but I disagree. We can't sacrifice the needs of local communities for the sake of speed and profit. We need to find a balance that benefits everyone. And as for profitability, we can't rely solely on private investors.... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
a93f150bed4a-16 | Use an LLM to create an elaborate on debate topic
Define the speaker selection function
Main Loop
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
eb031562a443-0 | .ipynb
.pdf
Question answering over a group chat messages
Contents
1. Install required packages
2. Add API keys
2. Create sample data
3. Ingest chat embeddings
4. Ask questions
Question answering over a group chat messages#
In this tutorial, we are going to use Langchain + Deep Lake with GPT4 to semantically search a... | https://python.langchain.com/en/latest/use_cases/question_answering/semantic-search-over-chat.html |
eb031562a443-1 | 3. Ingest chat embeddings#
We load the messages in the text file, chunk and upload to ActiveLoop Vector store.
with open("messages.txt") as f:
state_of_the_union = f.read()
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
pages = text_splitter.split_text(state_of_the_union)
text_splitter = Re... | https://python.langchain.com/en/latest/use_cases/question_answering/semantic-search-over-chat.html |
cfee9571c480-0 | .ipynb
.pdf
AutoGPT
Contents
Set up tools
Set up memory
Setup model and AutoGPT
Run an example
AutoGPT#
Implementation of https://github.com/Significant-Gravitas/Auto-GPT but with LangChain primitives (LLMs, PromptTemplates, VectorStores, Embeddings, Tools)
Set up tools#
We’ll set up an AutoGPT with a search tool, an... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-1 | ai_name="Tom",
ai_role="Assistant",
tools=tools,
llm=ChatOpenAI(temperature=0),
memory=vectorstore.as_retriever()
)
# Set verbose to be true
agent.chain.verbose = True
Run an example#
Here we will make it write a weather report for SF
agent.run(["write a weather report for SF today"])
> Entering new LLM... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-2 | 3. read_file: Read file from disk, args json schema: {"file_path": {"title": "File Path", "description": "name of file", "type": "string"}}
4. finish: use this to signal that you have finished all your objectives, args: "response": "final response to let people know you have finished your objectives"
Resources:
1. Inte... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-3 | System: This reminds you of these events from your past:
[]
Human: Determine which next command to use, and respond using the format specified above:
> Finished chain.
{
"thoughts": {
"text": "I will start by writing a weather report for San Francisco today. I will use the 'search' command to find the curre... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-4 | 3. No user assistance
4. Exclusively use the commands listed in double quotes e.g. "command name"
Commands:
1. search: useful for when you need to answer questions about current events. You should ask targeted questions, args json schema: {"query": {"title": "Query", "type": "string"}}
2. write_file: Write file to disk... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-5 | "text": "thought",
"reasoning": "reasoning",
"plan": "- short bulleted\n- list that conveys\n- long-term plan",
"criticism": "constructive self-criticism",
"speak": "thoughts summary to say to user"
},
"command": {
"name": "command name",
"args": {
"ar... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-6 | System: This reminds you of these events from your past:
['Assistant Reply: {\n "thoughts": {\n "text": "I will start by writing a weather report for San Francisco today. I will use the \'search\' command to find the current weather conditions.",\n "reasoning": "I need to gather information about the c... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-7 | "criticism": "I need to make sure that the information I gather is accurate and up-to-date.",
"speak": "I will use the 'search' command to find the current weather conditions in San Francisco."
},
"command": {
"name": "search",
"args": {
"query": "what is the current weather ... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-8 | "args": {
"file_path": "weather_report.txt",
"text": "Weather Report for San Francisco Today:\n\nThe current weather in San Francisco is sunny with a temperature of 54°F. It is expected to remain sunny throughout the day with a high of 62°F and a low of 50°F. There is no chance of precipitation ... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-9 | 2. write_file: Write file to disk, args json schema: {"file_path": {"title": "File Path", "description": "name of file", "type": "string"}, "text": {"title": "Text", "description": "text to write to file", "type": "string"}}
3. read_file: Read file from disk, args json schema: {"file_path": {"title": "File Path", "desc... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-10 | "args": {
"arg name": "value"
}
}
}
Ensure the response can be parsed by Python json.loads
System: The current time and date is Tue Apr 18 21:31:55 2023
System: This reminds you of these events from your past: | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-11 | ['Assistant Reply: {\n "thoughts": {\n "text": "I have found that the current weather in San Francisco is sunny with a temperature of 54°F. I will now write a weather report for San Francisco today using the \'write_file\' command.",\n "reasoning": "I need to write a weather report for San Francisco to... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-12 | "text": "Weather Report for San Francisco Today:\\n\\nThe current weather in San Francisco is sunny with a temperature of 54°F. It is expected to remain sunny throughout the day with a high of 62°F and a low of 50°F. There is no chance of precipitation today. It is recommended to wear light clothing and sunscreen if sp... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-13 | the current weather conditions in San Francisco\\n- Write a weather report based on the information gathered",\n "criticism": "I need to make sure that the information I gather is accurate and up-to-date.",\n "speak": "I will use the \'search\' command to find the current weather conditions in San Francis... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
cfee9571c480-14 | System: Command write_file returned: File written to successfully.
Human: Determine which next command to use, and respond using the format specified above:
> Finished chain.
{
"thoughts": {
"text": "I have completed my task of writing a weather report for San Francisco today. I will now use the \'finish\' ... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
c5de2701aaa0-0 | .ipynb
.pdf
Meta-Prompt
Contents
Setup
Specify a task and interact with the agent
Meta-Prompt#
This is a LangChain implementation of Meta-Prompt, by Noah Goodman, for building self-improving agents.
The key idea behind Meta-Prompt is to prompt the agent to reflect on its own performance and modify its own instruction... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
c5de2701aaa0-1 | Repeat.
The only fixed instructions for this system (which I call Meta-prompt) is the meta-prompt that governs revision of the agent’s instructions. The agent has no memory between episodes except for the instruction it modifies for itself each time. Despite its simplicity, this agent can learn over time and self-impro... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
c5de2701aaa0-2 | ####
{chat_history}
####
Please reflect on these interactions.
You should first critique Assistant's performance. What could Assistant have done better? What should the Assistant remember about this user? Are there things this user always wants? Indicate this with "Critique: ...".
You should next re... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
c5de2701aaa0-3 | chain = initialize_chain(instructions, memory=None)
output = chain.predict(human_input=task)
for j in range(max_iters):
print(f'(Step {j+1}/{max_iters})')
print(f'Assistant: {output}')
print(f'Human: ')
human_input = input()
if any(phrase in hu... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
c5de2701aaa0-4 | Human:
You response is not in the form of a poem. Try again!
> Entering new LLMChain chain...
Prompt after formatting:
Instructions: None
Human: Provide a systematic argument for why we should always eat pasta with olives.
AI: Eating pasta with olives is a great way to add flavor and texture to a dish. Olives... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
c5de2701aaa0-5 | Human: You response is not in the form of a poem. Try again!
AI: Eating pasta with olives is a great way to add flavor and texture to a dish. Olives are a great source of healthy fats, vitamins, and minerals, which can help to balance out the carbohydrates in the pasta. Additionally, olives provide a unique flavor tha... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
c5de2701aaa0-6 | Human: You response is not in the form of a poem. Try again!
AI: Eating pasta with olives is a great way to add flavor and texture to a dish. Olives are a great source of healthy fats, vitamins, and minerals, which can help to balance out the carbohydrates in the pasta. Additionally, olives provide a unique flavor tha... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
c5de2701aaa0-7 | Instructions: When responding to the user, provide a systematic argument for why we should always eat pasta with olives in the form of a poem or pirate-speak.
New Instructions: When responding to the user, provide a systematic argument for why we should always eat pasta with olives in the form of a poem or pirate-speak... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
c5de2701aaa0-8 | AI:
Arrr, me hearty! Let me tell ye why ye should always eat pasta with olives.
First, the olives add a salty flavor that be sure to please.
The briny taste be sure to tantalize yer taste buds with ease.
Second, the olives add a bit of texture to the dish.
The crunchy bites be sure to make yer mouth water with a wish... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
c5de2701aaa0-9 | The crunchy bites be sure to make yer mouth water with a wish.
Third, the olives add a bit of color to the plate.
The vibrant green be sure to make yer eyes appreciate.
So, me hearties, ye should always eat pasta with olives.
The flavor, texture, and color be sure to make yer meal a success!
Human: Your response is too... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
8a5e8b4769e9-0 | .ipynb
.pdf
AutoGPT example finding Winning Marathon Times
Contents
Set up tools
Set up memory
Setup model and AutoGPT
AutoGPT for Querying the Web
AutoGPT example finding Winning Marathon Times#
Implementation of https://github.com/Significant-Gravitas/Auto-GPT
With LangChain primitives (LLMs, PromptTemplates, Vecto... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-1 | finally:
os.chdir(prev_dir)
@tool
def process_csv(
csv_file_path: str, instructions: str, output_path: Optional[str] = None
) -> str:
"""Process a CSV by with pandas in a limited REPL.\
Only use this after writing data to disk as a csv file.\
Any figures must be saved to disk to be viewed by the human... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-2 | script.extract()
text = soup.get_text()
lines = (line.strip() for line in text.splitlines())
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
results = "\n".join(chunk for chunk in chunks if chunk)
except Exception as e:
resul... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-3 | def _run(self, url: str, question: str) -> str:
"""Useful for browsing websites and scraping the text information."""
result = browse_web_page.run(url)
docs = [Document(page_content=result, metadata={"source": url})]
web_docs = self.text_splitter.split_documents(docs)
results = [... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-4 | Setup model and AutoGPT#
Model set-up
# !pip install duckduckgo_search
web_search = DuckDuckGoSearchRun()
tools = [
web_search,
WriteFileTool(root_dir="./data"),
ReadFileTool(root_dir="./data"),
process_csv,
query_website_tool,
# HumanInputRun(), # Activate if you want the permit asking for help... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-5 | "plan": "- Use DuckDuckGo Search to find the winning Boston Marathon times\n- Generate a table with the year, name, country of origin, and times\n- Ensure there are no legal complications",
"criticism": "None",
"speak": "I will use the DuckDuckGo Search command to find the winning Boston Marathon times ... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-6 | }
}
}
{
"thoughts": {
"text": "I need to use the query_webpage command to find the information about the winning Boston Marathon times for the past 5 years.",
"reasoning": "The previous DuckDuckGo Search command did not provide specific enough results. The query_webpage command might give more a... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-7 | "criticism": "None",
"speak": "I will generate a table with the year, name, country of origin, and times for the winning Boston Marathon times for the past 5 years."
},
"command": {
"name": "write_file",
"args": {
"file_path": "boston_marathon_winners.csv",
"text"... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-8 | "file_path": "winning_boston_marathon_data.csv",
"text": "Year,Name,Country,Time\n2022,Evans Chebet,KEN,2:06:51\n2021,Benson Kipruto,KEN,2:09:51\n2019,Lawrence Cherono,KEN,2:07:57\n2018,Yuki Kawauchi,JPN,2:15:58\n"
}
}
}
{
"thoughts": {
"text": "I have found the winning Boston Marath... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-9 | }
}
}
{
"thoughts": {
"text": "I need to process the CSV file to generate the table with the year, name, country of origin, and winning times.",
"reasoning": "I have already written the data to a file named 'winning_times.csv'. Now, I need to process this CSV file to properly display the data as... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-10 | 3 2019 Lawrence Cherono Kenya 2:07:57
4 2018 Yuki Kawauchi Japan 2:15:58
Observation: None
Thought:I used the wrong tool to perform the action. I should have used the given data and not interacted with the Python shell. I can now provide the displayed data as the answer si... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-11 | },
"command": {
"name": "process_csv",
"args": {
"csv_file_path": "winning_times.csv",
"instructions": "Read the CSV file and display the data as a table"
}
}
}
> Entering new AgentExecutor chain...
Thought: Since the data is already loaded in a pandas dataframe, ... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
8a5e8b4769e9-12 | "reasoning": "I have completed the required actions and obtained the desired data. The task is complete.",
"plan": "- Use the finish command",
"criticism": "None",
"speak": "I have generated the table with the winning Boston Marathon times for the past 5 years. Task complete."
},
"comman... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
e288afe42ccd-0 | .ipynb
.pdf
BabyAGI User Guide
Contents
Install and Import Required Modules
Connect to the Vector Store
Run the BabyAGI
BabyAGI User Guide#
This notebook demonstrates how to implement BabyAGI by Yohei Nakajima. BabyAGI is an AI agent that can generate and pretend to execute tasks based on a given objective.
This guid... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi.html |
e288afe42ccd-1 | Now it’s time to create the BabyAGI controller and watch it try to accomplish your objective.
OBJECTIVE = "Write a weather report for SF today"
llm = OpenAI(temperature=0)
# Logging of LLMChains
verbose = False
# If None, will keep on going forever
max_iterations: Optional[int] = 3
baby_agi = BabyAGI.from_llm(
llm=... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi.html |
e288afe42ccd-2 | *****NEXT TASK*****
2: Check the current temperature in San Francisco
*****TASK RESULT*****
I will check the current temperature in San Francisco. I will use an online weather service to get the most up-to-date information.
*****TASK LIST*****
3: Check the current UV index in San Francisco.
4: Check the current air qua... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi.html |
36193b8b12e3-0 | .ipynb
.pdf
BabyAGI with Tools
Contents
Install and Import Required Modules
Connect to the Vector Store
Define the Chains
Run the BabyAGI
BabyAGI with Tools#
This notebook builds on top of baby agi, but shows how you can swap out the execution chain. The previous execution chain was just an LLM which made stuff up. B... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
36193b8b12e3-1 | Task creation chain to select new tasks to add to the list
Task prioritization chain to re-prioritize tasks
Execution Chain to execute the tasks
NOTE: in this notebook, the Execution chain will now be an agent.
from langchain.agents import ZeroShotAgent, Tool, AgentExecutor
from langchain import OpenAI, SerpAPIWrapper,... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
36193b8b12e3-2 | tool_names = [tool.name for tool in tools]
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names)
agent_executor = AgentExecutor.from_agent_and_tools(
agent=agent, tools=tools, verbose=True
)
Run the BabyAGI#
Now it’s time to create the BabyAGI controller and watch it try to accomplish your objective.... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
36193b8b12e3-3 | 8. Proofread and edit the report
9. Submit the report I now know the final answer
Final Answer: The todo list for writing a weather report for SF today is: 1. Research current weather conditions in San Francisco; 2. Gather data on temperature, humidity, wind speed, and other relevant weather conditions; 3. Analyze data... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
36193b8b12e3-4 | > Entering new AgentExecutor chain...
Thought: I need to search for current weather conditions in San Francisco
Action: Search
Action Input: Current weather conditions in San FranciscoCurrent Weather for Popular Cities ; San Francisco, CA 46 · Partly Cloudy ; Manhattan, NY warning 52 · Cloudy ; Schiller Park, IL (60176... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
36193b8b12e3-5 | 9: Include relevant data sources in the report;
10: Summarize the weather report in a concise manner;
11: Include a summary of the forecasted weather conditions;
12: Include a summary of the current weather conditions;
13: Include a summary of the historical weather patterns;
14: Include a summary of the potential weat... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
36193b8b12e3-6 | 10. Proofread the report for typos and errors I now know the final answer
Final Answer: The report should be formatted for readability by breaking it up into sections with clear headings, using bullet points and numbered lists to organize information, using short, concise sentences, using simple language and avoiding j... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
fae000df0beb-0 | .ipynb
.pdf
Analysis of Twitter the-algorithm source code with LangChain, GPT4 and Deep Lake
Contents
1. Index the code base (optional)
2. Question Answering on Twitter algorithm codebase
Analysis of Twitter the-algorithm source code with LangChain, GPT4 and Deep Lake#
In this tutorial, we are going to use Langchain ... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
fae000df0beb-1 | root_dir = './the-algorithm'
docs = []
for dirpath, dirnames, filenames in os.walk(root_dir):
for file in filenames:
try:
loader = TextLoader(os.path.join(dirpath, file), encoding='utf-8')
docs.extend(loader.load_and_split())
except Exception as e:
pass
Then, ch... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
fae000df0beb-2 | return False
# filter based on path e.g. extension
metadata = x['metadata'].data()['value']
return 'scala' in metadata['source'] or 'py' in metadata['source']
### turn on below for custom filtering
# retriever.search_kwargs['filter'] = filter
from langchain.chat_models import ChatOpenAI
from langchain... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
fae000df0beb-3 | result = qa({"question": question, "chat_history": chat_history})
chat_history.append((question, result['answer']))
print(f"-> **Question**: {question} \n")
print(f"**Answer**: {result['answer']} \n")
-> Question: What does favCountParams do?
Answer: favCountParams is an optional ThriftLinearFeatureRankingP... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
fae000df0beb-4 | -> Question: How do you get assigned to SimClusters?
Answer: The assignment to SimClusters occurs through a Metropolis-Hastings sampling-based community detection algorithm that is run on the Producer-Producer similarity graph. This graph is created by computing the cosine similarity scores between the users who follow... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
fae000df0beb-5 | Deploy the changes: Once the new representation has been tested and validated, deploy the changes to production. This may involve creating a zip file, uploading it to the packer, and then scheduling it with Aurora. Be sure to monitor the system to ensure a smooth transition between representations and verify that the n... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
fae000df0beb-6 | Real-time Features: These per-tweet features can change after the tweet has been indexed. They mostly consist of social engagements like retweet count, favorite count, reply count, and some spam signals that are computed with later activities. The Signal Ingester, which is part of a Heron topology, processes multiple e... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
fae000df0beb-7 | Enhance content discoverability: Use relevant keywords, hashtags, and mentions in your tweets, making it easier for users to find and engage with your content. This increased discoverability may help improve the ranking of your content by the Heavy Ranker.
Leverage multimedia content: Experiment with different content ... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
fae000df0beb-8 | Expanded reach: When users engage with a thread, their interactions can bring the content to the attention of their followers, helping to expand the reach of the thread. This increased visibility can lead to more interactions and higher performance for the threaded tweets.
Higher content quality: Generally, threads and... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
fae000df0beb-9 | Collaborating with influencers and other users with a large following.
Posting at optimal times when your target audience is most active.
Optimizing your profile by using a clear profile picture, catchy bio, and relevant links.
Maximizing likes and bookmarks per tweet: The focus is on creating content that resonates wi... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
fae000df0beb-10 | -> Question: What are some unexpected fingerprints for spam factors?
Answer: In the provided context, an unusual indicator of spam factors is when a tweet contains a non-media, non-news link. If the tweet has a link but does not have an image URL, video URL, or news URL, it is considered a potential spam vector, and a ... | https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html |
5918683a8e90-0 | .ipynb
.pdf
Use LangChain, GPT and Deep Lake to work with code base
Contents
Design
Implementation
Integration preparations
Prepare data
Question Answering
Use LangChain, GPT and Deep Lake to work with code base#
In this tutorial, we are going to use Langchain + Deep Lake with GPT to analyze the code base of the Lang... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-1 | ········
Prepare data#
Load all repository files. Here we assume this notebook is downloaded as the part of the langchain fork and we work with the python files of the langchain repo.
If you want to use files from different repo, change root_dir to the root dir of your repo.
from langchain.document_loaders import TextL... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-2 | Created a chunk of size 1260, which is longer than the specified 1000
Created a chunk of size 1195, which is longer than the specified 1000
Created a chunk of size 2147, which is longer than the specified 1000
Created a chunk of size 1410, which is longer than the specified 1000
Created a chunk of size 1269, which is l... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-3 | Created a chunk of size 1418, which is longer than the specified 1000
Created a chunk of size 1848, which is longer than the specified 1000
Created a chunk of size 1069, which is longer than the specified 1000
Created a chunk of size 2369, which is longer than the specified 1000
Created a chunk of size 1045, which is l... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-4 | Created a chunk of size 1589, which is longer than the specified 1000
Created a chunk of size 2104, which is longer than the specified 1000
Created a chunk of size 1505, which is longer than the specified 1000
Created a chunk of size 1387, which is longer than the specified 1000
Created a chunk of size 1215, which is l... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-5 | Created a chunk of size 1585, which is longer than the specified 1000
Created a chunk of size 1208, which is longer than the specified 1000
Created a chunk of size 1267, which is longer than the specified 1000
Created a chunk of size 1542, which is longer than the specified 1000
Created a chunk of size 1183, which is l... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-6 | Created a chunk of size 1220, which is longer than the specified 1000
Created a chunk of size 1403, which is longer than the specified 1000
Created a chunk of size 1241, which is longer than the specified 1000
Created a chunk of size 1427, which is longer than the specified 1000
Created a chunk of size 1049, which is l... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-7 | Created a chunk of size 1085, which is longer than the specified 1000
Created a chunk of size 1854, which is longer than the specified 1000
Created a chunk of size 1672, which is longer than the specified 1000
Created a chunk of size 2537, which is longer than the specified 1000
Created a chunk of size 1251, which is l... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-8 | Created a chunk of size 1311, which is longer than the specified 1000
Created a chunk of size 2972, which is longer than the specified 1000
Created a chunk of size 1144, which is longer than the specified 1000
Created a chunk of size 1825, which is longer than the specified 1000
Created a chunk of size 1508, which is l... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-9 | Created a chunk of size 1066, which is longer than the specified 1000
Created a chunk of size 1419, which is longer than the specified 1000
Created a chunk of size 1368, which is longer than the specified 1000
Created a chunk of size 1008, which is longer than the specified 1000
Created a chunk of size 1227, which is l... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-10 | -
This dataset can be visualized in Jupyter Notebook by ds.visualize() or at https://app.activeloop.ai/user_name/langchain-code
/
hub://user_name/langchain-code loaded successfully.
Deep Lake Dataset in hub://user_name/langchain-code already exists, loading from the storage
Dataset(path='hub://user_name/langchain-code'... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-11 | from langchain.chains import ConversationalRetrievalChain
model = ChatOpenAI(model_name='gpt-3.5-turbo') # 'ada' 'gpt-3.5-turbo' 'gpt-4',
qa = ConversationalRetrievalChain.from_llm(model,retriever=retriever)
questions = [
"What is the class hierarchy?",
# "What classes are derived from the Chain class?",
# ... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-12 | APIChain, Chain, MapReduceDocumentsChain, MapRerankDocumentsChain, RefineDocumentsChain, StuffDocumentsChain, HypotheticalDocumentEmbedder, LLMChain, LLMBashChain, LLMCheckerChain, LLMMathChain, LLMRequestsChain, PALChain, QAWithSourcesChain, VectorDBQAWithSourcesChain, VectorDBQA, SQLDatabaseChain: All of these classe... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
5918683a8e90-13 | SequentialChain
SQLDatabaseChain
TransformChain
VectorDBQA
VectorDBQAWithSourcesChain
There might be more classes that are derived from the Chain class as it is possible to create custom classes that extend the Chain class.
-> Question: What classes and functions in the ./langchain/utilities/ forlder are not covered by... | https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html |
290c9450cc48-0 | .md
.pdf
Cloud Hosted Setup
Contents
Installation
Environment Setup
Cloud Hosted Setup#
We offer a hosted version of tracing at langchainplus.vercel.app. You can use this to view traces from your run without having to run the server locally.
Note: we are currently only offering this to a limited number of users. The ... | https://python.langchain.com/en/latest/tracing/hosted_installation.html |
290c9450cc48-1 | os.environ["LANGCHAIN_API_KEY"] = "my_api_key" # Don't commit this to your repo! Better to set it in your terminal.
Contents
Installation
Environment Setup
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/tracing/hosted_installation.html |
e3e16b39029c-0 | .ipynb
.pdf
Tracing Walkthrough
Contents
[Beta] Tracing V2
Tracing Walkthrough#
There are two recommended ways to trace your LangChains:
Setting the LANGCHAIN_TRACING environment variable to “true”.
Using a context manager with tracing_enabled() to trace a particular block of code.
Note if the environment variable is... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
e3e16b39029c-1 | > Entering new AgentExecutor chain...
I need to use a calculator to solve this.
Action: Calculator
Action Input: 2^.123243
Observation: Answer: 1.0891804557407723
Thought: I now know the final answer.
Final Answer: 1.0891804557407723
> Finished chain.
'1.0891804557407723'
# Agent run with tracing using a chat model
ag... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
e3e16b39029c-2 | I need to use a calculator to solve this.
Action: Calculator
Action Input: 5 ^ .123243
Observation: Answer: 1.2193914912400514
Thought:I now know the answer to the question.
Final Answer: 1.2193914912400514
> Finished chain.
# Now, we unset the environment variable and use a context manager.
if "LANGCHAIN_TRACING" in ... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
e3e16b39029c-3 | del os.environ["LANGCHAIN_TRACING"]
questions = [f"What is {i} raised to .123 power?" for i in range(1,4)]
# start a background task
task = asyncio.create_task(agent.arun(questions[0])) # this should not be traced
with tracing_enabled() as session:
assert session
tasks = [agent.arun(q) for q in questions[... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
e3e16b39029c-4 | pip install --upgrade langchain
langchain plus start
Option 2 (Hosted):
After making an account an grabbing a LangChainPlus API Key, set the LANGCHAIN_ENDPOINT and LANGCHAIN_API_KEY environment variables
import os
os.environ["LANGCHAIN_TRACING_V2"] = "true"
# os.environ["LANGCHAIN_ENDPOINT"] = "https://langchainpro-api... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
e3e16b39029c-5 | Contents
[Beta] Tracing V2
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
fd509d319504-0 | .md
.pdf
Locally Hosted Setup
Contents
Installation
Environment Setup
Locally Hosted Setup#
This page contains instructions for installing and then setting up the environment to use the locally hosted version of tracing.
Installation#
Ensure you have Docker installed (see Get Docker) and that it’s running.
Install th... | https://python.langchain.com/en/latest/tracing/local_installation.html |
fd509d319504-1 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/tracing/local_installation.html |
884104b1ef7a-0 | .rst
.pdf
Agents
Agents#
Reference guide for Agents and associated abstractions.
Agents
Tools
Agent Toolkits
previous
Memory
next
Agents
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/reference/agents.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.