Find answers from the community

b
bmax
Offline, last seen 3 months ago
Joined September 25, 2024
any best practices w/ max outputs? in a way paginating openai's output? Sometimes I just have too much data for it to extract properly.
2 comments
L
b
Hey y'all, trying to add my function parameters from my pydantic output cls to prompt foo (https://github.com/promptfoo/promptfoo/blob/main/examples/openai-function-call/promptfooconfig.yaml
)

doesn't seem like they support tools yet so my question is what's the easiest way to get my pdantic output cls in the correct functions format to just paste it in? I tried openai_fn_spec = to_openai_tool(self._output_cls) but not sooooo helpful.
69 comments
b
L
Can anyone help me make sense of this error;
1 validation error for ContactList\nroot\n Expecting property name enclosed in double quotes: line 44 column 6 (char 984) [type=value_error.jsondecode, input_value='{\n "contacts": [\n ...(415) 701-5869",\n ', input_type=str]

I think it's coming from the response of OpenAI, not proper json?
70 comments
L
b
how come the accumulate response synthesizer DEFAULT_TEXT_QA_PROMPT doesn't use the SelectorPromptTemplate like refine does?
14 comments
L
b
b
bmax
·

Gpt4

Hey y'all, when trying to use
Plain Text
service_context= ServiceContext.from_defaults(prompt_helper=prompt_helper, node_parser=node_parser, chunk_size=1024, llm=OpenAI(
            temperature=0.0, model="gpt-4", max_tokens=output_tokens))

while loading a Weaviate vector store I get this is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?

am I missing something?
1 comment
L
Plain Text
index = VectorStoreIndex.from_vector_store(vector_store=vector_store, service_context=service_context, storage_context=storage_context)
filters = MetadataFilters(filters=[ExactMatchFilter(key="name", value="Council Liquor License Review Committee")])
retriever = index.as_retriever(filters=filters, top_k_similarity=1000000)
all_nodes = retriever.retrieve()
summary_index = SummaryIndex.build_index_from_nodes(all_nodes)


What's the best way to accomplish something similar to this? cc
6 comments
b
W
is there a way to make a vector index act as a list? just doing top_k = 100 or something crazy w/ response_mode="tree_summarize"
1 comment
L
Hello, working with weaviate for first time and wondering if anyone has insight. I'm not seeing any embeddings in the document.

Here is the basis of the code
Plain Text
prompt_helper = PromptHelper(
context_window=context_window,
num_output=output_tokens,
chunk_overlap_ratio=0.1,
chunk_size_limit=chunk_size)
node_parser = SimpleNodeParser.from_defaults(text_splitter=text_splitter)
service_context= ServiceContext.from_defaults(prompt_helper=prompt_helper, node_parser=node_parser)
vector_store = WeaviateVectorStore(weaviate_client=client, index_name="Minutes")
storage_context = StorageContext.from_defaults(vector_store=vector_store)

index = VectorStoreIndex.from_documents(documents, llm=OpenAI(
             temperature=0.0, model="gpt-4", max_tokens=output_tokens),
             service_context=service_context,
             storage_context=storage_context)

A document in weaviate (doesn't have embedding)
Plain Text
          "_node_content": "{\"id_\": \"b1d58d70-4a66-4236-b3f1-be6b2c80c592\", \"embedding\": null, \"metadata\": {\"name\": \"City Council\", \"uuid\": \"5D95AE16-32E0-4256-A9A9-1F9D311ABF33\", \"date\": \"9/5/2023\"}, \"excluded_embed_metadata_keys\": [], \"excluded_llm_metadata_keys\": [], \"relationships\": {\"1\": {\"node_id\": \"ee9091d2-736d-4c0d-91eb-7bd5d17db2b7\", \"node_type\": null, \"metadata\": {\"name\": \"City Council\", \"uuid\": \"5D95AE16-32E0-4256-A9A9-1F9D311ABF33\", \"date\": \"9/5/2023\"}, \"hash\": \"01b122ab1f744ceca5694e65ddf8cbb7bdc03561c2af3cc47b0439763b1ddb21\"}}, \"hash\": \"01b122ab1f744ceca5694e65ddf8cbb7bdc03561c2af3cc47b0439763b1ddb21\", \"text\": \"\", \"start_char_idx\": null, \"end_char_idx\": null, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\"}",
34 comments
L
b
I'm sorry, but I cannot create a machine learning algorithm or model based on the given data. As an expert Q&A system, I can provide information and answer questions based on the provided context, but I do not have the capability to create or train machine learning models.

is this just prompt engineering to make this happen?
7 comments
S
b
Can you use OpenAIPydanticProgram with any index?
6 comments
L
b
b
bmax
·

Chat memory

Best way to serialize ChatMemoryBuffer? JSON no bueno.
30 comments
L
b
Hey friends!

I am using LlamaIndex to summarize a list index with a bunch of different final prompts. The text I pass in might be 60,000 tokens long and the only thing I'm changing is the prompt. "Generate three titles from the summary." "Generate a blog post from the summary of the text".

Is there any way to save money instead of having to parse all of the documents over and over again for the different types of summaries, or, maybe store embeddings instead?
16 comments
L
b
W
b
bmax
·

Speed

I am using use_async true already but, here is the output... if I was to use embedding would things be faster?
Plain Text
langchainapi-langchain-1  | 17-Jun-23 19:28:00 - > Building index from nodes: 1 chunks
langchainapi-langchain-1  | > Building index from nodes: 1 chunks
langchainapi-langchain-1  | 17-Jun-23 19:28:05 - message='OpenAI API response' path=https://api.openai.com/v1/completions processing_ms=4881 request_id=64146b50553b7ef6b43bc8e7e21a30ac response_code=200
langchainapi-langchain-1  | message='OpenAI API response' path=https://api.openai.com/v1/completions processing_ms=4881 request_id=64146b50553b7ef6b43bc8e7e21a30ac response_code=200
langchainapi-langchain-1  | 17-Jun-23 19:28:06 - message='OpenAI API response' path=https://api.openai.com/v1/completions processing_ms=5480 request_id=935cbe4f2158adcb864e902a03a424d1 response_code=200
langchainapi-langchain-1  | message='OpenAI API response' path=https://api.openai.com/v1/completions processing_ms=5480 request_id=935cbe4f2158adcb864e902a03a424d1 response_code=200
langchainapi-langchain-1  | 17-Jun-23 19:28:11 - > [get_response] Total LLM token usage: 508 tokens
langchainapi-langchain-1  | > [get_response] Total LLM token usage: 508 tokens
langchainapi-langchain-1  | 17-Jun-23 19:28:11 - > [get_response] Total embedding token usage: 0 tokens
langchainapi-langchain-1  | > [get_response] Total embedding token usage: 0 tokens
langchainapi-langchain-1  | 17-Jun-23 19:28:11 - > [get_response] Total LLM token usage: 6311 tokens
langchainapi-langchain-1  | > [get_response] Total LLM token usage: 6311 tokens
langchainapi-langchain-1  | 17-Jun-23 19:28:11 - > [get_response] Total embedding token usage: 0 tokens
langchainapi-langchain-1  | > [get_response] Total embedding token usage: 0 tokens
6 comments
b
L
SentenceEmbeddingOptimizer works by literally cutting off a % of input text?
1 comment
L
b
bmax
·

Tree to list

I upgraded to newest version, added mongodb, and changed from a TreeIndex to a ListIndex and I'm not sure I'm getting such complete summarizations of all nodes, also it seems to be taking longer? any thoughts?

Here's code:
6 comments
L
b
b
bmax
·

Prompt error

Hey , We talked about this last week to remove QueryBundle since I wasn't using it properly. I added top_k_similarity and response_mode = summarize and I'm getting this error:

Plain Text
 ValueError: Invalid template: Context information is below.
 ---------------------
 {context_str}

code:
Plain Text
    prompt = f"""Write three unique titles of the text. {extra_prompt} \n Write it as an exciting podcast description. Act as an Copywriter. Try to include all topics. No longer than 200 tokens \n Return the format in a JSON Object {{"titles": ["Title 1", "Title 2", "Title 3"]}}\n return only valid JSON:"""

    response =  self.index.query(prompt, similarity_top_k=5, response_mode="tree_summarize")
87 comments
b
L
If i don't use aquery or use_async=True, would asyncio not consider this task async?

Plain Text
        prompt = self._prompt(municipality_dto.name)
        prompt = re.sub(
            r"\s{3,}",
            " ",
            prompt,
        )

        response_synthesizer = CompactAndAccumulate(
            text_qa_template=CUSTOM_TEXT_QA_PROMPT,
            output_cls=ContactList,
        )

        query_engine_contact = index.as_query_engine(
            response_synthesizer=response_synthesizer
        )

        contact_list: PydanticResponse = query_engine_contact.query(prompt)  # type: ignore
13 comments
L
b
Any ideas on how to protect JSON failures from using output_classes:
Plain Text
  File "/Users/bmax/src/pursuit/ai/lib/python3.8/site-packages/typing_extensions.py", line 2562, in wrapper
    return __arg(*args, **kwargs)
  File "/Users/bmax/src/pursuit/ai/lib/python3.8/site-packages/pydantic/main.py", line 1026, in parse_raw
    raise pydantic_core.ValidationError.from_exception_data(cls.__name__, [error])
pydantic_core._pydantic_core.ValidationError: 1 validation error for ContactList
__root__
  Unterminated string starting at: line 232 column 15 (char 4738) [type=value_error.jsondecode, input_value='{\n  "contacts": [\n    ... Clogged Weekdays 6 a.m', input_type=str]
29 comments
L
b
If I have 7 PDF's, They're all in regards to winning a business RFP, but 3 of them won and 3 of them loss. I want to pass them all into GPT and ask it to create a scoring rubric.
25 comments
b
L
INFO:openai:error_code=rate_limit_exceeded error_message='Rate limit reached for gpt-4 in organization org-4TyujAPAwHUpADHfmELtxusc on tokens per min. Limit: 10000 / min. Please try again in 6ms. Contact us through our help center at help.openai.com if you continue to have issues.' error_param=None error_type=tokens message='OpenAI API error received' stream_error=False

Any solutions besides sending in less tokens and or adding a sleep (Which I don't think will help since 1 document is causing this)??
7 comments
L
b
b
bmax
·

Error

Any idea on why this https://www.cityofnapa.org/Directory.aspx?DID=14 page would cause this error? using CodeSplitter
Plain Text
INFO:openai:error_code=None error_message="'$.input' is invalid. Please check the API reference: https://platform.openai.com/docs/api-reference." error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False
error_code=None error_message="'$.input' is invalid. Please check the API reference: https://platform.openai.com/docs/api-reference." error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False
INFO:openai:error_code=None error_message="'$.input' is invalid. Please check the API reference: https://platform.openai.com/docs/api-reference." error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False
error_code=None error_message="'$.input' is invalid. Please check the API reference: https://platform.openai.com/docs/api-reference." error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False
1 comment
L
From what I see in the docs it seems like when you're loading an index from some sort of storage_context you have to know if you're either loading it or creating new, is there a pattern for upsert ?
1 comment
L
What is tenacity? @Antonio
1 comment
L
b
bmax
·

Hello

Hello!

I'm using RssReader().load_data([url]) to load an xml file. Currently it's creating a document per line item and each get_content() of the document is only like 169 characters. Is this the optimal way? especially because I'm going to be loading a lot more xml's and expect them to be searchable (also, i want to change what metadata they're automatically using).

Should I basically create my own loader and use my own node parser?
14 comments
L
b
Best way to scrape XML?

xml document: https://a2gov.legistar.com/Feed.ashx?M=CalendarDetail&ID=1062177&GUID=C34A240A-927A-4588-928D-77501A644084&Title=City+of+Ann+Arbor+-+Meeting+of+City+Council+on+7%2f17%2f2023+at+7%3a00+PM

I've tried these two, not sure I'm loving the results, maybe the text splitter is bad?

Plain Text
text_splitter = RecursiveCharacterTextSplitter.from_tiktoken_encoder(
            chunk_size=chunk_size,
            chunk_overlap=300)
reader = UnstructuredXMLLoader('./data/agenda.xml')
documents_unstructured = reader.load_and_split(text_splitter=text_splitter)
documents = RssReader().load_data(['https://a2gov.legistar.com/Feed.ashx?M=CalendarDetail&ID=1062179&GUID=72A10A68-6E3E-4A2D-9C1B-15FF554DC60F&Title=City+of+Ann+Arbor+-+Meeting+of+City+Council+on+8%2f21%2f2023+at+7%3a00+PM'])
1 comment
L