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
from llama_index.agent import FnRetrieverOpenAIAgent | |
from llama_index.llms import OpenAI | |
# Initialize the LLM | |
llm = OpenAI(model="gpt-3.5-turbo-0613") | |
# Initialize the FnRetrieverOpenAIAgent | |
top_agent = FnRetrieverOpenAIAgent.from_retriever( | |
obj_index.as_retriever(similarity_top_k=4), | |
system_prompt=""" \ |
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
# Create vector_index instance | |
vector_index = VectorStoreIndex(nodes, service_context=service_context) | |
# Build the summary index | |
summary_index = SummaryIndex(nodes, service_context=service_context) | |
# Now you can safely define query engines since vector_index is defined | |
vector_query_engine = vector_index.as_query_engine() | |
summary_query_engine = summary_index.as_query_engine() |
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
from llama_index.agent import OpenAIAgent | |
from llama_index import load_index_from_storage, StorageContext | |
from llama_index.node_parser import SentenceSplitter | |
# Initialize the SentenceSplitter node parser | |
node_parser = SentenceSplitter() | |
#load documents and build vector index | |
for idx, patent_title in enumerate(patent_titles): | |
file_path = os.path.join(patents_dir, f"{patent_title}.txt") |
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
query_engine_tools = [ | |
QueryEngineTool( | |
query_engine=tesla_engine, | |
metadata=ToolMetadata( | |
name="tesla_tool", | |
description=( | |
"Provides information about Teslas predictions for future " | |
"Use a detailed plain text question as input to the tool." | |
), | |
), |
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
import llama_index | |
from llama_index.tools import QueryEngineTool, ToolMetadata | |
from llama_index import ( | |
SimpleDirectoryReader, | |
VectorStoreIndex, | |
StorageContext, | |
load_index_from_storage, | |
) | |
try: |
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
@bot.command() | |
async def dogsplain(ctx, *, question: str): | |
print(f"User: {ctx.author.name}, Query: {question}") | |
try: | |
response = chat_bot.query(question) | |
await send_response(ctx, response) | |
except Exception as e: | |
await send_response(ctx, "An error occurred. Please try again!") | |
print("Error occurred during 'query' command:", e) |
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
answer = bench_bot.query('how to submit benchmarks?') | |
print(answer) |
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
#pdf data arxiv on bench | |
bench_bot.add('https://arxiv.org/pdf/2207.10062.pdf', data_type='pdf_file') | |
#notion page data | |
bench_bot.add('https://signalism.notion.site/MLCommons-An-In-Depth-Whitepaper-on-Benchmarking-Machine-Learning-Performance-d21aabe85304439fb5ae4ca7ac3826f7?pvs=4') | |
#docs | |
bench_bot.add('https://docs.google.com/spreadsheets/d/1bF4buOnEPQcwoqlaSeX4HxKx8jVRR0xHcOT_CaAL5Mk/pubhtml?gid=0&single=false&widget=false&headers=false&chrome=true', data_type="docs_site") | |
#github as page |
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
# takes the transcript and load it with yt_loader ;) | |
bench_bot.add('youtube_video', 'https://www.youtube.com/watch?v=uMNtTBRCHXA') | |
bench_bot.add('youtube_video', 'https://www.youtube.com/watch?v=eyK-9UehYPo') | |
bench_bot.add('youtube_video', 'https://www.youtube.com/watch?v=woGaG3ZcTbU') | |
bench_bot.add('youtube_video', 'https://www.youtube.com/watch?v=woGaG3ZcTbU') | |
bench_bot.add('youtube_video', 'https://www.youtube.com/watch?v=txtvMhzEDu8') |
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
bench_bot.add('web_page', 'https://mlcommons.org/en/training-normal-30/') | |
bench_bot.add('web_page', 'https://mlcommons.org/en/training-hpc-20/') | |
bench_bot.add('web_page', 'https://mlcommons.org/en/inference-datacenter-30/') | |
bench_bot.add('web_page', 'https://mlcommons.org/en/inference-tiny-11/') | |
bench_bot.add('web_page', 'https://mlcommons.org/en/groups/datasets/') |
NewerOlder