Showing preview only (8,304K chars total). Download the full file or copy to clipboard to get everything.
Repository: tmc/langchaingo
Branch: main
Commit: 8fea3de63675
Files: 1148
Total size: 7.7 MB
Directory structure:
gitextract_818zmpj_/
├── .gitattributes
├── .github/
│ ├── FUNDING.yml
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── workflows/
│ ├── ci.yaml
│ ├── examples.yaml
│ └── publish-docs.yaml
├── .gitignore
├── .golangci-exp.yaml
├── .golangci.yaml
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── FIXES_SUMMARY.md
├── LICENSE
├── Makefile
├── README.md
├── agents/
│ ├── agents.go
│ ├── conversational.go
│ ├── conversational_test.go
│ ├── doc.go
│ ├── errors.go
│ ├── executor.go
│ ├── executor_test.go
│ ├── initialize.go
│ ├── markl_test.go
│ ├── mrkl.go
│ ├── mrkl_prompt.go
│ ├── ollama_agent_guide.md
│ ├── openai_functions_agent.go
│ ├── openai_functions_agent_test.go
│ ├── options.go
│ ├── prompts/
│ │ ├── conversational_format_instructions.txt
│ │ ├── conversational_prefix.txt
│ │ └── conversational_suffix.txt
│ └── testdata/
│ ├── TestConversationalWithMemory.httprr
│ ├── TestExecutorWithMRKLAgent.httprr
│ ├── TestExecutorWithOpenAIFunctionAgent.httprr
│ ├── TestOpenAIFunctionsAgentComplexCalculation.httprr
│ └── TestOpenAIFunctionsAgentWithHTTPRR.httprr
├── callbacks/
│ ├── agent_final_stream.go
│ ├── agent_final_stream_test.go
│ ├── callbacks.go
│ ├── callbacks_unit_test.go
│ ├── combining.go
│ ├── doc.go
│ ├── log.go
│ ├── log_stream.go
│ └── simple.go
├── chains/
│ ├── api.go
│ ├── api_test.go
│ ├── chains.go
│ ├── chains_test.go
│ ├── chains_unit_test.go
│ ├── constitution/
│ │ ├── constitutional.go
│ │ ├── constitutional_test.go
│ │ ├── principles.go
│ │ ├── prompts.go
│ │ └── testdata/
│ │ └── TestConstitutionalChain.httprr
│ ├── constitutional.go
│ ├── constitutional_test.go
│ ├── conversation.go
│ ├── conversation_test.go
│ ├── conversational_retrieval_qa.go
│ ├── conversational_retrieval_qa_test.go
│ ├── doc.go
│ ├── errors.go
│ ├── llm.go
│ ├── llm_azure_test.go
│ ├── llm_math.go
│ ├── llm_math_test.go
│ ├── llm_test.go
│ ├── map_reduce.go
│ ├── map_reduce_test.go
│ ├── map_rerank_documents.go
│ ├── map_rerank_documents_test.go
│ ├── options.go
│ ├── prompt_selector.go
│ ├── prompts/
│ │ ├── llm_api_url.txt
│ │ ├── llm_api_url_response.txt
│ │ └── llm_math.txt
│ ├── question_answering.go
│ ├── question_answering_test.go
│ ├── refine_documents.go
│ ├── retrieval_qa.go
│ ├── retrieval_qa_test.go
│ ├── sequential.go
│ ├── sequential_test.go
│ ├── sql_database.go
│ ├── sql_database_test.go
│ ├── stuff_documents.go
│ ├── stuff_documents_test.go
│ ├── summarization.go
│ ├── summarization_test.go
│ ├── testdata/
│ │ ├── TestConstitutionalChainBasic.httprr
│ │ ├── TestConversation.httprr
│ │ ├── TestConversationWithChatLLM.httprr
│ │ ├── TestConversationWithZepMemory.httprr
│ │ ├── TestLLMChain.httprr
│ │ ├── TestLLMChainAzure.httprr
│ │ ├── TestLLMChainWithGoogleAI.httprr
│ │ ├── TestLLMMath.httprr
│ │ ├── TestMapReduceQA.httprr
│ │ ├── TestMapReduceSummarization.httprr
│ │ ├── TestRefineQA.httprr
│ │ ├── TestRefineSummarization.httprr
│ │ ├── TestRetrievalQA.httprr
│ │ ├── TestRetrievalQAFromLLM.httprr
│ │ ├── TestSQLDatabaseChain_Call.httprr
│ │ ├── TestStuffDocuments.httprr
│ │ ├── TestStuffSummarization.httprr
│ │ └── mouse_story.txt
│ ├── transform.go
│ └── transform_test.go
├── doc.go
├── docs/
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── .vale.ini
│ ├── Makefile
│ ├── README.md
│ ├── babel.config.js
│ ├── code-block-loader.js
│ ├── docs/
│ │ ├── concepts/
│ │ │ ├── architecture.md
│ │ │ └── index.md
│ │ ├── contributing/
│ │ │ ├── documentation.md
│ │ │ └── index.md
│ │ ├── getting-started/
│ │ │ ├── guide-chat.mdx
│ │ │ ├── guide-mistral.mdx
│ │ │ ├── guide-ollama.mdx
│ │ │ └── guide-openai.mdx
│ │ ├── how-to/
│ │ │ ├── configure-llm-providers.md
│ │ │ └── index.md
│ │ ├── index.md
│ │ ├── modules/
│ │ │ ├── agents/
│ │ │ │ ├── agents/
│ │ │ │ │ └── index.mdx
│ │ │ │ ├── executor/
│ │ │ │ │ ├── getting-started.mdx
│ │ │ │ │ └── index.mdx
│ │ │ │ ├── index.mdx
│ │ │ │ └── tools/
│ │ │ │ └── index.mdx
│ │ │ ├── chains/
│ │ │ │ ├── index.mdx
│ │ │ │ └── llm_chain.mdx
│ │ │ ├── data_connection/
│ │ │ │ ├── document_loaders/
│ │ │ │ │ └── index.mdx
│ │ │ │ ├── index.mdx
│ │ │ │ ├── retrievers/
│ │ │ │ │ └── index.mdx
│ │ │ │ ├── text_splitters/
│ │ │ │ │ ├── examples/
│ │ │ │ │ │ └── index.mdx
│ │ │ │ │ └── index.mdx
│ │ │ │ └── vector_stores/
│ │ │ │ ├── index.mdx
│ │ │ │ └── pgvector.mdx
│ │ │ ├── memory/
│ │ │ │ ├── examples/
│ │ │ │ │ └── index.mdx
│ │ │ │ └── index.mdx
│ │ │ └── model_io/
│ │ │ ├── index.mdx
│ │ │ ├── models/
│ │ │ │ ├── chat/
│ │ │ │ │ ├── index.mdx
│ │ │ │ │ └── integrations.mdx
│ │ │ │ ├── embeddings/
│ │ │ │ │ ├── index.mdx
│ │ │ │ │ └── integrations.mdx
│ │ │ │ ├── index.mdx
│ │ │ │ └── llms/
│ │ │ │ ├── Integrations/
│ │ │ │ │ ├── fake.mdx
│ │ │ │ │ ├── groq.mdx
│ │ │ │ │ ├── huggingface.mdx
│ │ │ │ │ ├── llamafile.mdx
│ │ │ │ │ ├── local.mdx
│ │ │ │ │ ├── mistral.mdx
│ │ │ │ │ ├── openai.mdx
│ │ │ │ │ ├── vertexai.mdx
│ │ │ │ │ └── watsonx.mdx
│ │ │ │ └── index.mdx
│ │ │ ├── output_parsers/
│ │ │ │ └── index.mdx
│ │ │ └── prompts/
│ │ │ ├── index.mdx
│ │ │ └── prompt_templates/
│ │ │ ├── index.mdx
│ │ │ └── partial_values.mdx
│ │ └── tutorials/
│ │ ├── basic-chat-app.md
│ │ ├── code-reviewer.md
│ │ ├── index.md
│ │ ├── log-analyzer.md
│ │ └── smart-documentation.md
│ ├── docusaurus.config.js
│ ├── go.mod
│ ├── go.sum
│ ├── package.json
│ ├── parity_matrix.md
│ ├── search-indexer.go
│ ├── sidebars.js
│ ├── src/
│ │ ├── css/
│ │ │ └── custom.css
│ │ ├── pages/
│ │ │ └── index.js
│ │ └── theme/
│ │ ├── CodeBlock/
│ │ │ └── index.js
│ │ └── SearchBar/
│ │ ├── SearchBar.css
│ │ └── index.js
│ ├── static/
│ │ └── .nojekyll
│ └── styles/
│ └── langchaingo/
│ ├── ActiveVoice.yml
│ ├── Clarity.yml
│ ├── CodeBlockLanguage.yml
│ ├── ConsistentLists.yml
│ ├── DirectLanguage.yml
│ ├── ErrorHandling.yml
│ ├── HardcodedSecrets.yml
│ ├── Headers.yml
│ ├── IncompleteExamples.yml
│ ├── NoEmojis.yml
│ ├── PresentTense.yml
│ ├── Pronouns.yml
│ ├── Readability.yml
│ ├── Spelling.yml
│ ├── Terminology.yml
│ └── ignore.txt
├── documentloaders/
│ ├── assemblyai.go
│ ├── assemblyai_test.go
│ ├── csv.go
│ ├── csv_test.go
│ ├── directory.go
│ ├── directory_test.go
│ ├── doc.go
│ ├── documentloaders.go
│ ├── html.go
│ ├── html_test.go
│ ├── notion.go
│ ├── notion_test.go
│ ├── pdf.go
│ ├── pdf_test.go
│ ├── testdata/
│ │ ├── depth/
│ │ │ └── test2.md
│ │ ├── test.csv
│ │ ├── test.html
│ │ └── test.txt
│ ├── text.go
│ └── text_test.go
├── embeddings/
│ ├── bedrock/
│ │ ├── bedrock.go
│ │ ├── bedrock_test.go
│ │ ├── bedrock_unit_test.go
│ │ ├── options.go
│ │ ├── provider_amazon.go
│ │ └── provider_cohere.go
│ ├── cybertron/
│ │ ├── cybertron.go
│ │ ├── cybertron_test.go
│ │ ├── cybertron_unit_test.go
│ │ └── options.go
│ ├── doc.go
│ ├── embedding.go
│ ├── embedding_test.go
│ ├── example_test.go
│ ├── huggingface/
│ │ ├── huggingface.go
│ │ ├── huggingface_test.go
│ │ ├── huggingface_unit_test.go
│ │ └── options.go
│ ├── jina/
│ │ ├── jina.go
│ │ ├── jina_test.go
│ │ ├── jina_unit_test.go
│ │ └── options.go
│ ├── openai_test.go
│ ├── options.go
│ ├── testdata/
│ │ ├── TestOpenaiEmbeddings.httprr
│ │ ├── TestOpenaiEmbeddingsQueryVsDocuments.httprr
│ │ ├── TestOpenaiEmbeddingsWithAzureAPI.httprr
│ │ ├── TestOpenaiEmbeddingsWithOptions.httprr
│ │ ├── TestVertexAIPaLMEmbeddings.httprr
│ │ └── TestVertexAIPaLMEmbeddingsWithOptions.httprr
│ ├── vector_math.go
│ ├── vector_math_test.go
│ └── voyageai/
│ ├── options.go
│ ├── voyageai.go
│ ├── voyageai_test.go
│ └── voyageai_unit_test.go
├── examples/
│ ├── .gitattributes
│ ├── .update-all-to-latest.sh
│ ├── Makefile
│ ├── README.md
│ ├── anthropic-completion-example/
│ │ ├── README.md
│ │ ├── anthropic_completion_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── anthropic-extended-capabilities/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── anthropic-interleaved-thinking/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── anthropic-tool-call-example/
│ │ ├── README.md
│ │ ├── anthropic-tool-call-example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── anthropic-vision-example/
│ │ ├── README.md
│ │ ├── anthropic_vision_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── bedrock-claude3-vision-example/
│ │ ├── README.md
│ │ ├── becrock_claude3_vision_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── bedrock-provider-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── caching-llm-example/
│ │ ├── README.md
│ │ ├── caching_llm_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── chains-conversation-memory-sqlite/
│ │ ├── README.md
│ │ ├── chains_conversation_memory_sqlite.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── chroma-vectorstore-example/
│ │ ├── README.md
│ │ ├── chroma_vectorstore_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── cohere-llm-example/
│ │ ├── README.md
│ │ ├── cohere_completion_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── cybertron-embedding-example/
│ │ ├── README.md
│ │ ├── cybertron-embedding.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── deepseek-completion-example/
│ │ ├── deepseek-completion-example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── document-qa-example/
│ │ ├── README.md
│ │ ├── document_qa.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── ernie-chat-example/
│ │ ├── README.md
│ │ ├── ernie_chat_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── ernie-completion-example/
│ │ ├── README.md
│ │ ├── ernie_completion_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── ernie-function-call-example/
│ │ ├── README.md
│ │ ├── ernie_function_call_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── google-alloydb-chat-message-history-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── google_alloydb_chat_message_history_example.go
│ ├── google-alloydb-vectorstore-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── google_alloydb_vectorstore_example.go
│ ├── google-cloudsql-chat-message-history-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── google_cloudsql_chat_message_history_example.go
│ ├── google-cloudsql-vectorstore-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── google_cloudsql_vectorstore_example.go
│ ├── googleai-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── googleai-completion-example.go
│ ├── googleai-reasoning-caching/
│ │ └── main.go
│ ├── googleai-streaming-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── googleai-stremaing-example.go
│ ├── googleai-tool-call-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── googleai-tool-call-example.go
│ ├── groq-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── groq_completion_example.go
│ ├── huggingface-llm-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── huggingface_example.go
│ ├── huggingface-milvus-vectorstore-example/
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── Taskfile.yml
│ │ ├── docker-compose.yml
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── milvus_vectorstore_example.go
│ ├── json-mode-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── json_mode_example.go
│ ├── llamafile-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── llamafile_completion_example.go
│ ├── llm-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── llm_chain.go
│ ├── llmmath-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── llm_math_chain.go
│ ├── llmsummarization-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── llm_summarization_example.go
│ ├── local-llm-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── local_llm_example.go
│ ├── maritaca-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── maritaca-chat-example.go
│ ├── mistral-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── mistral_completion_example.go
│ ├── mistral-embedding-example/
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── mistral-embedding-example.go
│ ├── mistral-summarization-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── mistral_summarization_example.go
│ ├── mongovector-vectorstore-example/
│ │ ├── README.md
│ │ ├── docker-compose.yml
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── mongovector_vectorstore_example.go
│ ├── mrkl-agent-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── mrkl_agent.go
│ ├── nvidia-chat-completion/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── nvidia_chat_completion_example.go
│ ├── ollama-chat-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── ollama_chat_example.go
│ ├── ollama-chroma-vectorstore-example/
│ │ ├── README.md
│ │ ├── chroma_vectorstore_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── ollama-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── ollama_completion_example.go
│ ├── ollama-functions-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── ollama_functions_example.go
│ ├── ollama-reasoning-caching/
│ │ └── main.go
│ ├── ollama-stream-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── ollama_stream_example.go
│ ├── openai-chat-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── openai_chat_example.go
│ │ └── useragent-comparison.md
│ ├── openai-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_completion_example.go
│ ├── openai-completion-example-with-http-debugging/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_completion_example.go
│ ├── openai-embeddings-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai-embeddings-example.go
│ ├── openai-function-call-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_function_call_example.go
│ ├── openai-function-call-streaming-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_function_call_example.go
│ ├── openai-gpt4-turbo-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_gpt4_turbo.go
│ ├── openai-gpt4o-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── index.html
│ │ └── openai_gpt4o_example.go
│ ├── openai-gpt4o-mutil-content/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai-gpt4o-mutil-content.go
│ ├── openai-jsonformat-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai-jsonformat.go
│ ├── openai-o1-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_o1_chat_example.go
│ ├── openai-readme/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai-readme.go
│ ├── openrouter-llm-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openrouter_llm_example.go
│ ├── perplexity-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── perplexity_completion_example.go
│ ├── pgvector-vectorstore-example/
│ │ ├── README.md
│ │ ├── create_extension.sql
│ │ ├── docker-compose.yml
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── pgvector_vectorstore_example.go
│ │ └── postgres.Dockerfile
│ ├── pinecone-vectorstore-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── pinecone_vectorstore_example.go
│ ├── postgresql-database-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── postgresql_database_chain.go
│ ├── prompt-caching/
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── prompt-template-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── qdrant-vectorstore-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── qdrant_vectorstore_example.go
│ ├── reasoning-tokens/
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── redis-vectorstore-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── redis_vectorstore_example.go
│ ├── sequential-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── sequential_chain_example.go
│ ├── sql-database-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── sql_database_chain.go
│ ├── tutorial-basic-chat-app/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── main.go
│ │ ├── step3_basic.go
│ │ ├── step4_interactive.go
│ │ ├── step5_memory.go
│ │ └── step6_advanced.go
│ ├── vertex-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── vertex-completion-example.go
│ ├── vertex-embedding-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── vertex-embedding-example.go
│ ├── watsonx-llm-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── watsonx_example.go
│ ├── zapier-llm-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ └── zep-memory-chain-example/
│ ├── README.md
│ ├── go.mod
│ ├── go.sum
│ └── main.go
├── exp/
│ ├── README.md
│ └── doc.go
├── go.mod
├── go.sum
├── httputil/
│ ├── doc.go
│ ├── logging_transport.go
│ ├── transport.go
│ ├── transport_test.go
│ ├── useragent.go
│ └── useragent_test.go
├── internal/
│ ├── devtools/
│ │ ├── examples-updater/
│ │ │ └── main.go
│ │ ├── git-hooks/
│ │ │ ├── install-git-hooks.sh
│ │ │ └── pre-push
│ │ ├── lint/
│ │ │ ├── doc.go
│ │ │ └── lint.go
│ │ ├── normalize-recordings/
│ │ │ └── main.go
│ │ └── rrtool/
│ │ └── main.go
│ ├── httprr/
│ │ ├── README.md
│ │ ├── normalization_test.go
│ │ ├── rr.go
│ │ ├── rr_test.go
│ │ └── rr_unit_test.go
│ ├── imageutil/
│ │ ├── download.go
│ │ ├── download_test.go
│ │ └── download_unit_test.go
│ ├── maputil/
│ │ ├── map.go
│ │ └── map_test.go
│ ├── mongodb/
│ │ └── client.go
│ ├── setutil/
│ │ ├── set.go
│ │ └── set_test.go
│ ├── sliceutil/
│ │ ├── slice.go
│ │ └── slice_test.go
│ └── testutil/
│ └── testctr/
│ └── testctr.go
├── jsonschema/
│ ├── json.go
│ └── json_test.go
├── llms/
│ ├── anthropic/
│ │ ├── anthropicllm.go
│ │ ├── anthropicllm_option.go
│ │ ├── anthropicllm_test.go
│ │ ├── errors.go
│ │ ├── internal/
│ │ │ └── anthropicclient/
│ │ │ ├── anthropicclient.go
│ │ │ ├── anthropicclient_test.go
│ │ │ ├── completions.go
│ │ │ ├── messages.go
│ │ │ ├── messages_test.go
│ │ │ └── testdata/
│ │ │ ├── TestClient_CreateMessage.httprr
│ │ │ ├── TestClient_CreateMessageStream.httprr
│ │ │ └── TestClient_WithAnthropicBetaHeader.httprr
│ │ ├── llmtest_test.go
│ │ ├── options.go
│ │ ├── options_test.go
│ │ └── prompt_caching_test.go
│ ├── bedrock/
│ │ ├── bedrock_tool_integration_test.go
│ │ ├── bedrockllm.go
│ │ ├── bedrockllm_option.go
│ │ ├── bedrockllm_test.go
│ │ ├── bedrockllm_unit_test.go
│ │ ├── errors.go
│ │ ├── internal/
│ │ │ └── bedrockclient/
│ │ │ ├── bedrockclient.go
│ │ │ ├── bedrockclient_integration_test.go
│ │ │ ├── bedrockclient_nova_test.go
│ │ │ ├── bedrockclient_test.go
│ │ │ ├── provider_ai21.go
│ │ │ ├── provider_amazon.go
│ │ │ ├── provider_anthropic.go
│ │ │ ├── provider_cohere.go
│ │ │ ├── provider_meta.go
│ │ │ ├── provider_nova.go
│ │ │ ├── tool_call_test.go
│ │ │ └── tools.go
│ │ ├── llmtest_test.go
│ │ ├── models_list.go
│ │ ├── testdata/
│ │ │ ├── TestAmazonNova.httprr
│ │ │ ├── TestAmazonOutput.httprr
│ │ │ ├── TestAnthropicNovaImage.httprr
│ │ │ └── TestBedrockAnthropicToolCalling.httprr
│ │ └── tool_call_test.go
│ ├── cache/
│ │ ├── cache.go
│ │ ├── cache_test.go
│ │ ├── doc.go
│ │ ├── inmemory/
│ │ │ ├── inmemory.go
│ │ │ ├── inmemory_test.go
│ │ │ └── options.go
│ │ └── mocks_test.go
│ ├── chat_messages.go
│ ├── chat_messages_test.go
│ ├── cloudflare/
│ │ ├── cloudflarellm.go
│ │ ├── cloudflarellm_test.go
│ │ ├── internal/
│ │ │ └── cloudflareclient/
│ │ │ ├── api.go
│ │ │ ├── api_test.go
│ │ │ ├── client.go
│ │ │ ├── cloudflareclient_test.go
│ │ │ ├── model.go
│ │ │ └── role.go
│ │ ├── llmtest_test.go
│ │ └── options.go
│ ├── cohere/
│ │ ├── coherellm.go
│ │ ├── coherellm_option.go
│ │ ├── coherellm_test.go
│ │ ├── errors.go
│ │ ├── internal/
│ │ │ └── cohereclient/
│ │ │ ├── cohereclient.go
│ │ │ ├── cohereclient_test.go
│ │ │ └── testdata/
│ │ │ ├── TestClient_CreateGeneration.httprr
│ │ │ └── TestClient_CreateGenerationWithCustomModel.httprr
│ │ ├── llmtest_test.go
│ │ └── testdata/
│ │ ├── TestCallbacksHandler.httprr
│ │ └── TestGenerateContent.httprr
│ ├── compliance/
│ │ ├── doc.go
│ │ ├── example_test.go
│ │ └── suite.go
│ ├── count_tokens.go
│ ├── count_tokens_test.go
│ ├── doc.go
│ ├── ernie/
│ │ ├── doc.go
│ │ ├── erniellm.go
│ │ ├── erniellm_option.go
│ │ ├── erniellm_test.go
│ │ ├── internal/
│ │ │ └── ernieclient/
│ │ │ ├── chat.go
│ │ │ ├── client_unit_test.go
│ │ │ ├── ernieclient.go
│ │ │ └── ernieclient_test.go
│ │ └── llmtest_test.go
│ ├── errors.go
│ ├── errors_mapper.go
│ ├── errors_test.go
│ ├── fake/
│ │ ├── fakellm.go
│ │ ├── fakellm_test.go
│ │ └── llmtest_test.go
│ ├── generatecontent.go
│ ├── generatecontent_test.go
│ ├── googleai/
│ │ ├── README.md
│ │ ├── caching.go
│ │ ├── embeddings.go
│ │ ├── embeddings_unit_test.go
│ │ ├── errors.go
│ │ ├── googleai.go
│ │ ├── googleai_core_unit_test.go
│ │ ├── googleai_test.go
│ │ ├── googleai_unit_test.go
│ │ ├── internal/
│ │ │ ├── cmd/
│ │ │ │ └── generate-vertex.go
│ │ │ └── palmclient/
│ │ │ ├── palm_client_option.go
│ │ │ ├── palmclient.go
│ │ │ └── palmclient_unit_test.go
│ │ ├── llmtest_test.go
│ │ ├── new.go
│ │ ├── option.go
│ │ ├── palm/
│ │ │ ├── palm_llm.go
│ │ │ ├── palm_llm_option.go
│ │ │ └── palm_llm_test.go
│ │ ├── reasoning_test.go
│ │ ├── shared_test/
│ │ │ └── shared_test.go
│ │ ├── testdata/
│ │ │ ├── TestGoogleAIBatchEmbedding.httprr
│ │ │ ├── TestGoogleAICall.httprr
│ │ │ ├── TestGoogleAICreateEmbedding.httprr
│ │ │ ├── TestGoogleAIErrorHandling.httprr
│ │ │ ├── TestGoogleAIGenerateContent.httprr
│ │ │ ├── TestGoogleAIGenerateContentWithMultipleMessages.httprr
│ │ │ ├── TestGoogleAIGenerateContentWithSystemMessage.httprr
│ │ │ ├── TestGoogleAIMultiModalContent.httprr
│ │ │ ├── TestGoogleAIToolCallResponse.httprr
│ │ │ ├── TestGoogleAIWithHarmThreshold.httprr
│ │ │ ├── TestGoogleAIWithJSONMode.httprr
│ │ │ ├── TestGoogleAIWithOptions.httprr
│ │ │ ├── TestGoogleAIWithStreaming.httprr
│ │ │ └── TestGoogleAIWithTools.httprr
│ │ └── vertex/
│ │ ├── embeddings.go
│ │ ├── embeddings_test.go
│ │ ├── new.go
│ │ ├── new_test.go
│ │ ├── vertex.go
│ │ ├── vertex_test.go
│ │ └── vertex_unit_test.go
│ ├── huggingface/
│ │ ├── example_provider_test.go
│ │ ├── huggingfacellm.go
│ │ ├── huggingfacellm_option.go
│ │ ├── huggingfacellm_test.go
│ │ ├── internal/
│ │ │ └── huggingfaceclient/
│ │ │ ├── embeddings.go
│ │ │ ├── huggingfaceclient.go
│ │ │ ├── huggingfaceclient_test.go
│ │ │ ├── inference.go
│ │ │ └── testdata/
│ │ │ ├── TestClient_RunInference.httprr
│ │ │ ├── TestClient_RunInferenceText2Text.httprr
│ │ │ └── TestClient_RunInferenceWithProvider.httprr
│ │ ├── llmtest_test.go
│ │ └── testdata/
│ │ ├── TestHuggingFaceLLMStandardInference.httprr
│ │ └── TestHuggingFaceLLMWithProvider.httprr
│ ├── llamafile/
│ │ ├── internal/
│ │ │ └── llamafileclient/
│ │ │ ├── llamafileclient.go
│ │ │ ├── llamafileclient_test.go
│ │ │ └── types.go
│ │ ├── llamafilellm.go
│ │ ├── llamafilellm_test.go
│ │ ├── llmtest_test.go
│ │ └── options.go
│ ├── llms.go
│ ├── local/
│ │ ├── internal/
│ │ │ └── localclient/
│ │ │ ├── completions.go
│ │ │ ├── doc.go
│ │ │ ├── localclient.go
│ │ │ └── localclient_test.go
│ │ ├── llmtest_test.go
│ │ ├── localllm.go
│ │ ├── localllm_option.go
│ │ └── localllm_test.go
│ ├── maritaca/
│ │ ├── internal/
│ │ │ └── maritacaclient/
│ │ │ ├── maritacaclient.go
│ │ │ ├── maritacaclient_test.go
│ │ │ ├── maritacaclient_unit_test.go
│ │ │ ├── types.go
│ │ │ └── types_test.go
│ │ ├── llmtest_test.go
│ │ ├── maritaca_test.go
│ │ ├── maritacallm.go
│ │ ├── maritacallm_unit_test.go
│ │ └── options.go
│ ├── marshaling.go
│ ├── marshaling_test.go
│ ├── mistral/
│ │ ├── client_options.go
│ │ ├── errors.go
│ │ ├── llmtest_test.go
│ │ ├── mistralembed.go
│ │ ├── mistralembed_test.go
│ │ ├── mistralmodel.go
│ │ └── mistralmodel_test.go
│ ├── ollama/
│ │ ├── context_cache.go
│ │ ├── internal/
│ │ │ └── ollamaclient/
│ │ │ ├── ollamaclient.go
│ │ │ ├── ollamaclient_test.go
│ │ │ ├── testdata/
│ │ │ │ ├── TestClient_CreateEmbedding.httprr
│ │ │ │ ├── TestClient_Generate.httprr
│ │ │ │ ├── TestClient_GenerateChat.httprr
│ │ │ │ ├── TestClient_GenerateChatStream.httprr
│ │ │ │ ├── TestClient_GenerateChatWithThink.httprr
│ │ │ │ └── TestClient_GenerateStream.httprr
│ │ │ └── types.go
│ │ ├── llmtest_test.go
│ │ ├── ollama_test.go
│ │ ├── ollamallm.go
│ │ ├── options.go
│ │ ├── reasoning_test.go
│ │ └── testdata/
│ │ ├── TestCreateEmbedding.httprr
│ │ ├── TestGenerateContent.httprr
│ │ ├── TestWithFormat.httprr
│ │ ├── TestWithKeepAlive.httprr
│ │ ├── TestWithPullModel.httprr
│ │ ├── TestWithPullTimeout.httprr
│ │ ├── TestWithStreaming.httprr
│ │ └── TestWithThink.httprr
│ ├── openai/
│ │ ├── doc.go
│ │ ├── errors.go
│ │ ├── internal/
│ │ │ └── openaiclient/
│ │ │ ├── chat.go
│ │ │ ├── chat_sse_test.go
│ │ │ ├── chat_test.go
│ │ │ ├── completions.go
│ │ │ ├── embeddings.go
│ │ │ ├── marshal_test.go
│ │ │ ├── openaiclient.go
│ │ │ ├── openaiclient_test.go
│ │ │ └── testdata/
│ │ │ ├── TestClient_CreateChatCompletion.httprr
│ │ │ ├── TestClient_CreateChatCompletionStream.httprr
│ │ │ ├── TestClient_CreateEmbedding.httprr
│ │ │ ├── TestClient_CreateEmbeddingWithDimensions.httprr
│ │ │ ├── TestClient_FunctionCall.httprr
│ │ │ └── TestClient_WithResponseFormat.httprr
│ │ ├── llm.go
│ │ ├── llmtest_test.go
│ │ ├── max_tokens_test.go
│ │ ├── multicontent_test.go
│ │ ├── openaillm.go
│ │ ├── openaillm_option.go
│ │ ├── openrouter_httprr_test.go
│ │ ├── openrouter_streaming_test.go
│ │ ├── options.go
│ │ ├── options_test.go
│ │ ├── structured_output_test.go
│ │ └── testdata/
│ │ ├── TestFunctionCall.httprr
│ │ ├── TestMultiContentImage.httprr
│ │ ├── TestMultiContentText.httprr
│ │ ├── TestMultiContentTextChatSequence.httprr
│ │ ├── TestOpenRouterStreaming.httprr
│ │ ├── TestOpenRouterWithHTTPRR.httprr
│ │ ├── TestStructuredOutputFunctionCalling.httprr
│ │ ├── TestStructuredOutputObjectAndArraySchema.httprr
│ │ ├── TestStructuredOutputObjectSchema.httprr
│ │ └── TestWithStreaming.httprr
│ ├── options.go
│ ├── options_test.go
│ ├── prompt_caching.go
│ ├── prompt_caching_test.go
│ ├── prompts.go
│ ├── prompts_test.go
│ ├── reasoning.go
│ ├── reasoning_test.go
│ ├── token_utilization_test.go
│ └── watsonx/
│ ├── llmtest_test.go
│ └── watsonxllm.go
├── memory/
│ ├── alloydb/
│ │ ├── README.md
│ │ ├── chat_message_history.go
│ │ ├── chat_message_history_options.go
│ │ ├── chat_message_history_test.go
│ │ └── chat_message_history_unit_test.go
│ ├── buffer.go
│ ├── buffer_options.go
│ ├── buffer_test.go
│ ├── chat.go
│ ├── chat_options.go
│ ├── chat_test.go
│ ├── cloudsql/
│ │ ├── README.md
│ │ ├── chat_message_history.go
│ │ └── chat_message_history_options.go
│ ├── doc.go
│ ├── mongo/
│ │ ├── main_test.go
│ │ ├── mongo_chat_history.go
│ │ ├── mongo_chat_history_options.go
│ │ └── mongo_chat_history_test.go
│ ├── simple.go
│ ├── sqlite3/
│ │ ├── sqlite3_history.go
│ │ ├── sqlite3_history_options.go
│ │ └── sqlite3_history_test.go
│ ├── testdata/
│ │ ├── TestTokenBufferMemory.httprr
│ │ ├── TestTokenBufferMemoryReturnMessage.httprr
│ │ └── TestTokenBufferMemoryWithPreLoadedHistory.httprr
│ ├── token_buffer.go
│ ├── token_buffer_test.go
│ ├── window_buffer.go
│ ├── window_buffer_test.go
│ └── zep/
│ ├── zep_chat_history.go
│ ├── zep_chat_history_options.go
│ ├── zep_memory.go
│ ├── zep_memory_options.go
│ └── zep_test.go
├── outputparser/
│ ├── boolean_parser.go
│ ├── boolean_parser_test.go
│ ├── combining.go
│ ├── combining_test.go
│ ├── comma_seperated_list.go
│ ├── comma_seperated_list_test.go
│ ├── defined.go
│ ├── defined_test.go
│ ├── doc.go
│ ├── parser_additional_test.go
│ ├── regex_dict.go
│ ├── regex_dict_test.go
│ ├── regex_parser.go
│ ├── regex_parser_test.go
│ ├── simple.go
│ ├── structured.go
│ └── structured_test.go
├── prompts/
│ ├── chat_prompt.go
│ ├── chat_prompt_template.go
│ ├── chat_prompt_template_test.go
│ ├── doc.go
│ ├── example_selector.go
│ ├── examples_test.go
│ ├── few_shot.go
│ ├── few_shot_test.go
│ ├── internal/
│ │ ├── fstring/
│ │ │ ├── doc.go
│ │ │ ├── fstring.go
│ │ │ ├── fstring_test.go
│ │ │ └── parser.go
│ │ ├── loader/
│ │ │ └── secure_loader.go
│ │ └── sanitization/
│ │ └── sanitize.go
│ ├── message_prompt_template.go
│ ├── prompt_template.go
│ ├── prompt_template_test.go
│ ├── prompt_test.go
│ ├── prompts.go
│ ├── render_options.go
│ ├── security_test.go
│ ├── string_prompt.go
│ ├── templates.go
│ ├── templates_go.go
│ ├── templates_jinja2.go
│ ├── templates_test.go
│ ├── testdata/
│ │ ├── article.j2
│ │ ├── header.j2
│ │ └── main.j2
│ └── validation_test.go
├── schema/
│ ├── chat_message_history.go
│ ├── doc.go
│ ├── documents.go
│ ├── memory.go
│ ├── output_parsers.go
│ ├── retrivers.go
│ └── schema.go
├── test_all_fixes.sh
├── testing/
│ └── llmtest/
│ ├── doc.go
│ ├── llmtest.go
│ └── llmtest_test.go
├── textsplitter/
│ ├── doc.go
│ ├── markdown_splitter.go
│ ├── markdown_splitter_test.go
│ ├── options.go
│ ├── recursive_character.go
│ ├── recursive_character_test.go
│ ├── split_documents.go
│ ├── testdata/
│ │ ├── example.md
│ │ └── example_markdown_header_512.md
│ ├── text_spliter.go
│ ├── token_splitter.go
│ └── token_splitter_test.go
├── tools/
│ ├── calculator.go
│ ├── doc.go
│ ├── duckduckgo/
│ │ ├── ddg.go
│ │ ├── ddg_test.go
│ │ ├── doc.go
│ │ ├── internal/
│ │ │ └── client.go
│ │ └── testdata/
│ │ └── TestDuckDuckGoTool.httprr
│ ├── metaphor/
│ │ ├── doc.go
│ │ ├── documents.go
│ │ ├── links.go
│ │ ├── metaphor.go
│ │ ├── metaphor_test.go
│ │ └── search.go
│ ├── perplexity/
│ │ ├── doc.go
│ │ ├── perplexity.go
│ │ ├── perplexity_test.go
│ │ └── testdata/
│ │ ├── TestPerplexityTool.httprr
│ │ └── TestTool_Integration.httprr
│ ├── scraper/
│ │ ├── doc.go
│ │ ├── options.go
│ │ └── scraper.go
│ ├── serpapi/
│ │ ├── doc.go
│ │ ├── internal/
│ │ │ └── client.go
│ │ ├── options.go
│ │ ├── serpapi.go
│ │ ├── serpapi_test.go
│ │ └── testdata/
│ │ └── TestSerpAPITool.httprr
│ ├── sqldatabase/
│ │ ├── mysql/
│ │ │ ├── main_test.go
│ │ │ ├── mysql.go
│ │ │ └── mysql_test.go
│ │ ├── postgresql/
│ │ │ ├── main_test.go
│ │ │ ├── postgresql.go
│ │ │ └── postgresql_test.go
│ │ ├── sql_database.go
│ │ ├── sqlite3/
│ │ │ ├── sqlite3.go
│ │ │ └── sqlite3_test.go
│ │ └── testdata/
│ │ └── db.sql
│ ├── tool.go
│ ├── wikipedia/
│ │ ├── client.go
│ │ ├── doc.go
│ │ ├── testdata/
│ │ │ └── TestWikipedia.httprr
│ │ ├── wikipedia.go
│ │ └── wikipedia_test.go
│ └── zapier/
│ ├── description.go
│ ├── doc.go
│ ├── internal/
│ │ ├── client.go
│ │ ├── client_test.go
│ │ ├── client_unit_test.go
│ │ └── errors.go
│ ├── toolkit.go
│ ├── zapier.go
│ └── zapier_test.go
├── util/
│ ├── alloydbutil/
│ │ ├── engine.go
│ │ ├── engine_test.go
│ │ ├── options.go
│ │ └── options_test.go
│ └── cloudsqlutil/
│ ├── engine.go
│ ├── engine_test.go
│ ├── options.go
│ └── options_test.go
└── vectorstores/
├── alloydb/
│ ├── README.md
│ ├── distance_strategy.go
│ ├── main_test.go
│ ├── testdata/
│ │ ├── TestAddDocuments.httprr
│ │ ├── TestContainerApplyVectorIndexAndDropIndex.httprr
│ │ └── TestContainerIsValidIndex.httprr
│ ├── vectorstore.go
│ ├── vectorstore_container_test.go
│ ├── vectorstore_options.go
│ └── vectorstore_test.go
├── azureaisearch/
│ ├── azureaisearch.go
│ ├── azureaisearch_httprr_test.go
│ ├── azureaisearch_unit_test.go
│ ├── doc.go
│ ├── document_upload.go
│ ├── documents_search.go
│ ├── helpers.go
│ ├── helpers_http.go
│ ├── index_create.go
│ ├── index_delete.go
│ ├── index_list.go
│ ├── index_retrieve.go
│ ├── options.go
│ └── types.go
├── bedrockknowledgebases/
│ ├── bedrockknowledgebases.go
│ ├── bedrockknowledgebases_test.go
│ ├── doc.go
│ ├── ingestion.go
│ ├── options.go
│ └── s3.go
├── chroma/
│ ├── README.md
│ ├── chroma.go
│ ├── chroma_test.go
│ ├── doc.go
│ ├── embedder.go
│ ├── main_test.go
│ └── options.go
├── cloudsql/
│ ├── README.md
│ ├── distance_strategy.go
│ ├── main_test.go
│ ├── testdata/
│ │ ├── TestAddDocuments.httprr
│ │ ├── TestContainerApplyVectorIndexAndDropIndex.httprr
│ │ └── TestContainerIsValidIndex.httprr
│ ├── vectorstore.go
│ ├── vectorstore_container_test.go
│ ├── vectorstore_options.go
│ └── vectorstore_test.go
├── doc.go
├── dolt/
│ ├── doc.go
│ ├── dolt.go
│ ├── dolt_test.go
│ └── options.go
├── mariadb/
│ ├── doc.go
│ ├── main_test.go
│ ├── mariadb.go
│ ├── mariadb_test.go
│ └── options.go
├── milvus/
│ ├── main_test.go
│ ├── milvus.go
│ ├── milvus_test.go
│ ├── options.go
│ └── v2/
│ ├── README.md
│ ├── example_migration.go
│ ├── milvus.go
│ ├── milvus_test.go
│ └── options.go
├── mongovector/
│ ├── doc.go
│ ├── mock_embedder.go
│ ├── mock_llm.go
│ ├── mongovector.go
│ ├── mongovector_test.go
│ └── option.go
├── opensearch/
│ ├── doc.go
│ ├── document_indexing.go
│ ├── index_create.go
│ ├── index_delete.go
│ ├── main_test.go
│ ├── opensearch.go
│ ├── opensearch_test.go
│ ├── options.go
│ └── types.go
├── options.go
├── pgvector/
│ ├── doc.go
│ ├── main_test.go
│ ├── options.go
│ ├── pgvector.go
│ ├── pgvector_test.go
│ └── testdata/
│ └── TestDeduplicater.httprr
├── pinecone/
│ ├── doc.go
│ ├── options.go
│ ├── pinecone.go
│ ├── pinecone_test.go
│ ├── pinecone_unit_test.go
│ └── testdata/
│ └── TestPineconeStoreRest.httprr
├── qdrant/
│ ├── doc.go
│ ├── options.go
│ ├── qdrant.go
│ ├── qdrant_test.go
│ ├── qdrant_unit_test.go
│ ├── rest.go
│ └── schema.go
├── redisvector/
│ ├── doc.go
│ ├── index_schema.go
│ ├── index_schema_test.go
│ ├── index_search.go
│ ├── main_test.go
│ ├── options.go
│ ├── redis_client.go
│ ├── redis_vector.go
│ ├── redis_vector_test.go
│ └── testdata/
│ ├── TestCreateRedisVectorOptions.httprr
│ ├── schema.json
│ └── schema.yml
├── vectorstores.go
└── weaviate/
├── doc.go
├── main_test.go
├── options.go
├── testdata/
│ └── TestDeduplicater.httprr
├── weaviate.go
└── weaviate_test.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Mark httprr recording files as generated
*.httprr linguist-generated=true
*.httprr.gz linguist-generated=true
# Preserve exact line endings in httprr files (HTTP protocol requirement)
*.httprr -text
*.httprr.gz binary
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
github: tmc
================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
### PR Checklist
- [ ] Read the [Contributing documentation](https://github.com/tmc/langchaingo/blob/main/CONTRIBUTING.md).
- [ ] Read the [Code of conduct documentation](https://github.com/tmc/langchaingo/blob/main/CODE_OF_CONDUCT.md).
- [ ] Name your Pull Request title clearly, concisely, and prefixed with the name of the primarily affected package you changed according to [Good commit messages](https://go.dev/doc/contribute#commit_messages) (such as `memory: add interfaces for X, Y` or `util: add whizzbang helpers`).
- [ ] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
- [ ] Provide a description in this PR that addresses **what** the PR is solving, or reference the issue that it solves (e.g. `Fixes #123`).
- [ ] Describes the source of new concepts.
- [ ] References existing implementations as appropriate.
- [ ] Contains test coverage for new functions.
- [ ] Passes all [`golangci-lint`](https://golangci-lint.run/) checks.
================================================
FILE: .github/workflows/ci.yaml
================================================
# GitHub Actions CI workflow for langchaingo.
name: CI
on:
push:
branches:
- main
- 'test-*'
pull_request:
branches:
- main
permissions:
contents: read
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
check-latest: false
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.1.6
args: --timeout=5m
skip-cache: false
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
check-latest: false
- name: Build
run: go build -v ./...
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
check-latest: false
- name: Get Go version
id: go-version
run: |
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
echo "Go version: $GO_VERSION"
echo "version=$GO_VERSION" >> $GITHUB_OUTPUT
- name: Test
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GENAI_API_KEY: ${{ secrets.GENAI_API_KEY }}
run: |
go test -v -json -coverprofile=coverage-${{ steps.go-version.outputs.version }}.out ./... | tee test-results-${{ steps.go-version.outputs.version }}.ndjson
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-go${{ steps.go-version.outputs.version }}.ndjson
path: |
test-results-${{ steps.go-version.outputs.version }}.ndjson
coverage-${{ steps.go-version.outputs.version }}.out
test-race:
name: test -race
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
check-latest: false
- name: Test with Race Detector
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GENAI_API_KEY: ${{ secrets.GENAI_API_KEY }}
run: go test -v -json ./... -race | tee test-results-race-${{ steps.go-version.outputs.version }}.ndjson
- name: Upload race test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-race-go${{ steps.go-version.outputs.version }}.ndjson
path: test-results-race-${{ steps.go-version.outputs.version }}.ndjson
coverage:
name: coverage
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
cache: true
check-latest: false
- name: Download all test results
uses: actions/download-artifact@v4
with:
pattern: test-results-*
path: test-results
- name: Generate coverage report
run: |
# Find the latest Go version coverage file (highest version number)
COVERAGE_FILE=$(find test-results -name "coverage-*.out" -type f | sort -V | tail -1)
if [ -z "$COVERAGE_FILE" ]; then
echo "No coverage file found"
exit 1
fi
# Extract Go version from filename
GO_VERSION=$(basename "$COVERAGE_FILE" | sed 's/coverage-//' | sed 's/.out//')
# Generate coverage reports
go tool cover -html="$COVERAGE_FILE" -o coverage.html
go tool cover -func="$COVERAGE_FILE" -o coverage.txt
# Extract total coverage percentage
TOTAL_COVERAGE=$(go tool cover -func="$COVERAGE_FILE" | grep total | awk '{print $3}')
# Get all tested Go versions
TESTED_VERSIONS=$(find test-results -name "coverage-*.out" -type f | sed 's/.*coverage-//' | sed 's/.out//' | sort -V | paste -sd, -)
# Get workflow run URL
WORKFLOW_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# Create markdown summary
cat > coverage-summary.md << EOF
## Test Coverage: ${TOTAL_COVERAGE}
**Go versions tested:** ${TESTED_VERSIONS}
[Download Coverage Report](${WORKFLOW_URL}#artifacts) • [View Workflow](${WORKFLOW_URL})
EOF
# Output to GitHub Actions summary
cat coverage-summary.md >> $GITHUB_STEP_SUMMARY
- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
id: coverage-artifact
with:
name: coverage-report-html
path: |
coverage.html
coverage.txt
coverage-summary.md
test-results/**/coverage-*.out
- name: Add artifact URL to summary
if: steps.coverage-artifact.outputs.artifact-url != ''
run: |
cat >> $GITHUB_STEP_SUMMARY << EOF
---
### Direct Artifact Link
[**Download Coverage Report**](${{ steps.coverage-artifact.outputs.artifact-url }})
> **Note:** You must be logged in to GitHub to download this artifact.
EOF
================================================
FILE: .github/workflows/examples.yaml
================================================
name: Build Examples
on:
push: {}
pull_request:
branches:
- main
permissions:
contents: read
jobs:
discover-examples:
name: Discover Examples
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: |
# Find all example directories and create a JSON array
examples=$(find ./examples -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort | jq -R -s -c 'split("\n")[:-1]')
echo "matrix={\"example\":$examples}" >> $GITHUB_OUTPUT
echo "Found examples: $examples"
build-example:
name: Build ${{ matrix.example }}
needs: discover-examples
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.discover-examples.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
check-latest: false
cache-dependency-path: |
go.sum
examples/${{ matrix.example }}/go.sum
- name: Build ${{ matrix.example }}
run: |
cd examples/${{ matrix.example }}
echo "Building ${{ matrix.example }}"
go mod tidy
go build -o /dev/null .
================================================
FILE: .github/workflows/publish-docs.yaml
================================================
name: Deploy to GitHub Pages
on:
workflow_dispatch:
push:
paths:
- 'docs/**'
- '.github/workflows/publish-docs.yaml'
permissions:
contents: read
pages: write
id-token: write
pull-requests: write
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: ${{ github.ref == 'refs/heads/main' && 'github-pages' || 'preview' }}
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
cache-dependency-path: docs/pnpm-lock.yaml
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Build search index
working-directory: docs
run: go run search-indexer.go
- name: Build docs
working-directory: docs
run: |
pnpm install --frozen-lockfile
pnpm run build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/build
name: github-pages
- name: Deploy
id: deployment
if: |
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/docs-test' ||
startsWith(github.ref, 'refs/heads/docs/')
uses: actions/deploy-pages@v4
with:
artifact_name: github-pages
preview: ${{ github.ref != 'refs/heads/main' }}
- name: Comment PR
if: |
github.event_name == 'pull_request' &&
(github.ref == 'refs/heads/docs-test' ||
startsWith(github.ref, 'refs/heads/docs/'))
uses: actions/github-script@v7
with:
script: |
const url = '${{ steps.deployment.outputs.page_url }}';
const message = `📚 Documentation preview available at: ${url}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
================================================
FILE: .gitignore
================================================
go.work
go.work.sum
# Test outputs
coverage.out
cover.cov
# macOS Specific
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# IDE
.idea
.vscode
# dev
.env
.env.local
vendor/*
service-account.json
# IDE specific files
.idea/
.vscode/
*.swp
*.swo
embeddings/cybertron/models/*
examples/cybertron-embedding-example/models/*
================================================
FILE: .golangci-exp.yaml
================================================
linters:
presets:
- bugs
- comment
================================================
FILE: .golangci.yaml
================================================
version: "2"
linters:
default: none
enable:
- errcheck
- govet
- ineffassign
- staticcheck
- unused
- forbidigo
- funlen
- gosec
- misspell
settings:
cyclop:
max-complexity: 12
forbidigo:
forbid:
- pattern: import "[^"]+/(util|common|helpers)"
funlen:
lines: 90
gosec:
excludes:
- G115
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- internal
- vectorstores/bedrockknowledgebases
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Code of Conduct - langchaingo
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, or to ban
temporarily or permanently any contributor for other behaviors that they deem
inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at <travis.cline@gmail.com>.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org/), version
[1.4](https://www.contributor-covenant.org/version/1/4/code-of-conduct/code_of_conduct.md) and
[2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct/code_of_conduct.md).
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to langchaingo
First off, thanks for taking the time to contribute! ❤️
All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉
> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
> - Star the project
> - Tweet about it
> - Refer this project in your project's readme
> - Mention the project at local meetups and tell your friends/colleagues
## Table of Contents
- [Code of Conduct](#code-of-conduct)
- [I Have a Question](#i-have-a-question)
- [I Want To Contribute](#i-want-to-contribute)
- [Reporting Bugs](#reporting-bugs)
- [Before Submitting a Bug Report](#before-submitting-a-bug-report)
- [How Do I Submit a Good Bug Report?](#how-do-i-submit-a-good-bug-report)
- [Suggesting Enhancements](#suggesting-enhancements)
- [Before Submitting an Enhancement](#before-submitting-an-enhancement)
- [How Do I Submit a Good Enhancement Suggestion?](#how-do-i-submit-a-good-enhancement-suggestion)
- [Your First Code Contribution](#your-first-code-contribution)
- [Make Changes](#make-changes)
- [Make changes in the UI](#make-changes-in-the-ui)
- [Make changes locally](#make-changes-locally)
- [Running Tests](#running-tests)
- [Testing with httprr](#testing-with-httprr)
- [How httprr works](#how-httprr-works)
- [Writing tests with httprr](#writing-tests-with-httprr)
- [Recording new tests](#recording-new-tests)
- [Important notes about httprr](#important-notes-about-httprr)
- [Debugging httprr issues](#debugging-httprr-issues)
- [Commit your update](#commit-your-update)
- [Pull Request](#pull-request)
- [Your PR is merged!](#your-pr-is-merged)
## Code of Conduct
This project and everyone participating in it is governed by the
[langchaingo Code of Conduct](CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable behavior
to <travis.cline@gmail.com>.
## I Have a Question
> If you want to ask a question, we assume that you have read the available [Documentation](https://pkg.go.dev/github.com/tmc/langchaingo).
Before you ask a question, it is best to search for existing [Issues](https://github.com/tmc/langchaingo/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
If you then still feel the need to ask a question and need clarification, we recommend the following:
- Open an [Issue](https://github.com/tmc/langchaingo/issues/new).
- Provide as much context as you can about what you're running into.
- Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.
We will then take care of the issue as soon as possible.
## I Want To Contribute
> ### Legal Notice
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
### Reporting Bugs
#### Before Submitting a Bug Report
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://pkg.go.dev/github.com/tmc/langchaingo). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/tmc/langchaingo/issues?q=label%3Abug).
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
- Collect information about the bug:
- Stack trace (Traceback)
- OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant.
- Possibly your input and the output
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
#### How Do I Submit a Good Bug Report?
> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to <travis.cline@gmail.com>.
<!-- You may add a PGP key to allow the messages to be sent encrypted as well. -->
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
- Open an [Issue](https://github.com/tmc/langchaingo/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.
Once it's filed:
- The project team will label the issue accordingly.
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).
<!-- You might want to create an issue template for bugs and errors that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->
### Suggesting Enhancements
This section guides you through submitting an enhancement suggestion for langchaingo, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.
#### Before Submitting an Enhancement
- Make sure that you are using the latest version.
- Read the [documentation](https://pkg.go.dev/github.com/tmc/langchaingo) carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/tmc/langchaingo/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
#### How Do I Submit a Good Enhancement Suggestion?
Enhancement suggestions are tracked as [GitHub issues](https://github.com/tmc/langchaingo/issues).
- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. <!-- this should only be included if the project has a GUI -->
- **Explain why this enhancement would be useful** to most langchaingo users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
- We strive to conceptually align with the Python and TypeScript versions of Langchain. Please link/reference the associated concepts in those codebases when introducing a new concept.
<!-- You might want to create an issue template for enhancement suggestions that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->
### Your First Code Contribution
#### Make Changes
##### Make changes in the UI
Click **Make a contribution** at the bottom of any docs page to make small changes such as a typo, sentence fix, or a broken link. This takes you to the `.md` file where you can make your changes and [create a pull request](#pull-request) for a review.
##### Make changes locally
1. Fork the repository.
- Using GitHub Desktop:
- [Getting started with GitHub Desktop](https://docs.github.com/en/desktop/installing-and-configuring-github-desktop/getting-started-with-github-desktop) will guide you through setting up Desktop.
- Once Desktop is set up, you can use it to [fork the repo](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/cloning-and-forking-repositories-from-github-desktop)!
- Using the command line:
- [Fork the repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#fork-an-example-repository) so that you can make your changes without affecting the original project until you're ready to merge them.
2. Install or make sure **Golang** is updated.
3. Create a working branch and start with your changes!
##### Recent Updates and Dependencies
Be aware of these recent changes when contributing:
- **HTTP Client Standardization**: All HTTP clients now use `httputil.DefaultClient` with custom User-Agent headers (`langchaingo/{version}`)
- **HuggingFace Environment Variables**: Supports multiple token sources in priority order: `HF_TOKEN`, `HUGGINGFACEHUB_API_TOKEN`, token file from `HF_TOKEN_PATH`, or default `~/.cache/huggingface/token`
- **OpenAI Functions Agent**: Updated to handle OpenAI's new tool calling API while maintaining backward compatibility
- **Chroma Vector Store**: Updated to use `github.com/amikos-tech/chroma-go` v0.1.4+
- **Testcontainers Migration**: New testcontainers API using `Run()` instead of deprecated `RunContainer()` where supported
- **HTTPRR Files**: No longer compressed - commit `.httprr` files directly to the repository
##### Project Structure and Conventions
When making changes, follow these architectural conventions:
- **HTTP Clients**: Use `httputil.DefaultClient` instead of `http.DefaultClient` for all HTTP operations to ensure proper User-Agent headers
- **Interface-based Design**: Core functionality is defined through interfaces (Model, Chain, Memory, etc.)
- **Provider Isolation**: Each LLM/embedding provider has its own package with internal client implementation
- **Options Pattern**: Use functional options for configuration (see existing examples)
- **Context Propagation**: All operations should accept `context.Context` for cancellation and deadlines
- **Error Handling**: Use standardized error types and mapping (see `llms.Error` and provider error mappers)
##### Adding a New LLM Provider
When adding a new LLM provider:
1. Create a new package under `/llms/your-provider`
2. Implement the `llms.Model` interface
3. Create an internal client package for HTTP interactions
4. Use `httputil.DefaultClient` for HTTP requests
5. Add compliance tests: `compliance.NewSuite("yourprovider", model).Run(t)`
6. Add tests with httprr recordings for HTTP calls
7. Follow the existing provider patterns for options and error handling
##### Adding a New Vector Store
When adding a new vector store:
1. Create a new package under `/vectorstores/your-store`
2. Implement the vector store interface
3. Use testcontainers for integration tests where possible
4. Follow existing patterns for distance strategies and metadata filtering
#### Running Tests
Before submitting your changes, make sure all tests pass:
```bash
# Run all tests
make test
# Run tests for a specific package
go test ./chains
# Run a specific test
go test -run TestLLMChain ./chains
# Run tests with race detection
make test-race
# Run tests with coverage
make test-cover
# Test separation scripts
./scripts/run_unit_tests.sh # Run only unit tests (no external dependencies)
./scripts/run_all_tests.sh # Run complete test suite
./scripts/run_integration_tests.sh # Run only integration tests (requires Docker)
# Record HTTP interactions for tests (when adding new tests)
go test -httprecord=. -v ./path/to/package
```
Also ensure your code passes linting:
```bash
# Run linter
make lint
# Run linter with auto-fix
make lint-fix
# Run experimental linter configuration
make lint-exp
# Run all linters including experimental
make lint-all
# Clean lint cache
make clean-lint-cache
# Development tools
make build-examples # Build all examples to verify they compile
make docs # Generate documentation
make run-pkgsite # Run local documentation server
make install-git-hooks # Install git hooks (sets up pre-push hook)
make pre-push # Run lint and fast tests (suitable for git pre-push hook)
```
##### Additional Development Tools
The project includes several development tools in `/internal/devtools`:
```bash
# Custom linting tools
make lint-devtools # Run custom architectural lints
make lint-devtools-fix # Run custom lints with auto-fix
make lint-architecture # Run architectural validation
make lint-prepush # Run pre-push lints
make lint-prepush-fix # Run pre-push lints with auto-fix
# HTTPRR management
go run ./internal/devtools/rrtool list-packages # List packages using httprr
make test-record # Re-record all HTTP interactions
# Test pattern validation
make lint-testing # Check for incorrect httprr test patterns
make lint-testing-fix # Attempt to fix httprr test patterns automatically
```
#### Testing with httprr
This project uses a custom HTTP record/replay system (httprr) for testing HTTP interactions with external APIs. This allows tests to run deterministically without requiring actual API credentials or making real API calls.
##### How httprr works
- **Recording mode**: When tests run with real API credentials, httprr records all HTTP requests and responses to `.httprr` files in the `testdata` directory.
- **Replay mode**: When tests run without credentials, httprr replays the recorded HTTP interactions from the `.httprr` files.
- **Automatic mode switching**: Tests automatically skip if no credentials and no recording are available, with a helpful message.
##### Writing tests with httprr
When writing tests that make HTTP calls to external APIs, follow this pattern:
```go
func TestMyFeature(t *testing.T) {
t.Parallel()
ctx := context.Background()
// Skip if no credentials and no recording
httprr.SkipIfNoCredentialsAndRecordingMissing(t, "OPENAI_API_KEY")
// Set up httprr (automatically cleaned up via t.Cleanup)
// Use httputil.DefaultTransport for User-Agent headers, or http.DefaultTransport for simpler cases
rr := httprr.OpenForTest(t, httputil.DefaultTransport)
var opts []openai.Option
opts = append(opts, openai.WithHTTPClient(rr.Client()))
// Use test token when replaying
if !rr.Recording() {
opts = append(opts, openai.WithToken("test-api-key"))
}
// When recording, the client will use the real API key from environment
client, err := openai.New(opts...)
require.NoError(t, err)
// Run your test
result, err := client.Call(ctx, "test input")
require.NoError(t, err)
// ... assertions ...
}
```
This pattern ensures:
- **When recording**: Uses real API key from environment to capture valid responses
- **When replaying**: Uses "test-api-key" to satisfy client validation (httprr intercepts before actual API calls)
For other providers, use their specific options:
```go
// HuggingFace example (supports multiple environment variables)
func TestHuggingFace(t *testing.T) {
// HuggingFace supports both HF_TOKEN and HUGGINGFACEHUB_API_TOKEN
if os.Getenv("HF_TOKEN") == "" && os.Getenv("HUGGINGFACEHUB_API_TOKEN") == "" {
httprr.SkipIfNoCredentialsAndRecordingMissing(t, "HF_TOKEN")
}
rr := httprr.OpenForTest(t, httputil.DefaultTransport)
apiKey := "test-api-key"
if rr.Recording() {
if key := os.Getenv("HF_TOKEN"); key != "" {
apiKey = key
} else if key := os.Getenv("HUGGINGFACEHUB_API_TOKEN"); key != "" {
apiKey = key
}
}
llm, err := huggingface.New(
huggingface.WithHTTPClient(rr.Client()),
huggingface.WithToken(apiKey),
)
// ...
}
// Perplexity example
var opts []perplexity.Option
opts = append(opts, perplexity.WithHTTPClient(rr.Client()))
if !rr.Recording() {
opts = append(opts, perplexity.WithAPIKey("test-api-key"))
}
tool, err := perplexity.New(opts...)
// SerpAPI example with request scrubbing
rr.ScrubReq(func(req *http.Request) error {
if req.URL != nil {
q := req.URL.Query()
q.Set("api_key", "test-api-key")
req.URL.RawQuery = q.Encode()
}
return nil
})
```
For tests that need to create clients multiple times, consider using a helper function:
```go
func newOpenAILLM(t *testing.T) *openai.LLM {
t.Helper()
httprr.SkipIfNoCredentialsAndRecordingMissing(t, "OPENAI_API_KEY")
rr := httprr.OpenForTest(t, httputil.DefaultTransport)
// Only run tests in parallel when not recording (to avoid rate limits)
if !rr.Recording() {
t.Parallel()
}
var opts []openai.Option
opts = append(opts, openai.WithHTTPClient(rr.Client()))
if !rr.Recording() {
opts = append(opts, openai.WithToken("test-api-key"))
}
// When recording, openai.New() will read OPENAI_API_KEY from environment
llm, err := openai.New(opts...)
require.NoError(t, err)
return llm
}
```
##### Recording new tests
To record HTTP interactions for new tests:
1. Set the required environment variables (e.g., `OPENAI_API_KEY`)
2. Run the test with recording enabled:
```bash
go test -v -httprecord=. ./path/to/package
# To avoid rate limits, you can control parallelism:
go test -v -httprecord=. -p 1 -parallel=1 ./path/to/package
# Or use the Makefile target to record all packages
make test-record
```
3. The test will create `.httprr` files in the `testdata` directory
4. Commit these recording files with your PR
5. For tests that require API key scrubbing, add request scrubbing functions
##### Important notes about httprr
- **Transport choice**: Use `httputil.DefaultTransport` for User-Agent headers, or `http.DefaultTransport` for simpler cases
- **Check rr.Recording()**: Use this to conditionally add test tokens only when replaying
- **httprr handles cleanup**: OpenForTest automatically registers cleanup with t.Cleanup()
- **Real keys for recording**: When recording, let the client use the real API key from environment
- **Test tokens for replay**: When replaying, use "test-api-key" to satisfy client validation
- **Parallel testing**: Only run `t.Parallel()` when not recording to avoid hitting API rate limits
- **Multiple credential sources**: For HuggingFace, check both `HF_TOKEN` and `HUGGINGFACEHUB_API_TOKEN`
- **Request scrubbing**: Use `rr.ScrubReq()` for APIs that need URL parameter scrubbing (like SerpAPI)
- **Recordings are deterministic**: The same inputs should produce the same outputs
- **Sensitive data is scrubbed**: httprr automatically removes authorization headers and other sensitive data from recordings
- **Commit recording files**: Always commit the `.httprr` files so tests can run in CI without credentials
- **Delete invalid recordings**: If a test fails due to an invalid recording (e.g., 401 error), delete the recording file and re-record with valid credentials
##### Debugging httprr issues
- Use `-httprecord-debug` flag for detailed recording information
- Use `-httpdebug` flag to see actual HTTP traffic
- Check if recordings exist: `ls testdata/*.httprr`
- Verify recording contents: `head testdata/TestName.httprr`
- Use test separation scripts to isolate unit vs integration test issues:
```bash
./scripts/run_unit_tests.sh # Fast tests without external dependencies
./scripts/run_integration_tests.sh # Tests requiring Docker/external services
```
##### Automated httprr pattern validation
The project includes a custom linter to detect incorrect httprr usage patterns:
```bash
# Check for incorrect patterns
make lint-testing
# See specific issues found
go run ./internal/devtools/lint -testing -v
```
The linter detects:
- **Hardcoded test tokens**: `WithToken("test-api-key")` called unconditionally (should be conditional on `!rr.Recording()`)
- **Incorrect parallel execution**: `t.Parallel()` called before httprr setup (should be conditional on `!rr.Recording()`)
These issues cause authentication errors during recording and race conditions during testing.
#### Commit your update
Commit the changes once you are happy with them. Don't forget to self-review to speed up the review process:zap:.
#### Pull Request
When you're finished with the changes, create a pull request, also known as a PR.
- Name your Pull Request title clearly, concisely, and prefixed with the name of primarily affected package you changed according to [Go Contribute Guideline](https://go.dev/doc/contribute#commit_messages). (such as `memory: add interfaces` or `util: add helpers`)
- Run all linters and ensure tests pass: `make lint && make test`
- If you added new HTTP-based functionality, include httprr recordings
- **We strive to conceptually align with the Python and TypeScript versions of Langchain. Please link/reference the associated concepts in those codebases when introducing a new concept.**
- Fill the "Ready for review" template so that we can review your PR. This template helps reviewers understand your changes as well as the purpose of your pull request.
- Don't forget to [link PR to issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) if you are solving one.
- Enable the checkbox to [allow maintainer edits](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork) so the branch can be updated for a merge.
Once you submit your PR, a team member will review your proposal. We may ask questions or request additional information.
- We may ask for changes to be made before a PR can be merged, either using [suggested changes](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request) or pull request comments. You can apply suggested changes directly through the UI. You can make any other changes in your fork, then commit them to your branch.
- As you update your PR and apply changes, mark each conversation as [resolved](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request#resolving-conversations).
- If you run into any merge issues, checkout this [git tutorial](https://github.com/skills/resolve-merge-conflicts) to help you resolve merge conflicts and other issues.
#### Your PR is merged!
Congratulations :tada::tada: The langchaingo team thanks you :sparkles:.
Once your PR is merged, your contributions will be publicly visible on the repository contributors list.
Now that you are part of the community!
================================================
FILE: FIXES_SUMMARY.md
================================================
# High Priority Bug Fixes Summary
## Overview
This branch contains fixes for three high-priority issues affecting the langchaingo agents system.
## Fixed Issues
### 1. Agent Executor Max Iterations Bug (#1225)
**Problem**: Agents using models like llama2/llama3 would not finish before reaching max iterations, even when they had the answer.
**Root Cause**: The MRKL agent's `parseOutput` function was too strict in looking for exactly "Final Answer:" which some models don't consistently generate.
**Fix**: Enhanced the `parseOutput` function in `agents/mrkl.go` to:
- Accept case-insensitive variations of "final answer"
- Recognize alternative phrases like "the answer is:" and "answer:"
- Support flexible spacing and punctuation
- Maintain backward compatibility with the original format
**Files Modified**:
- `agents/mrkl.go` - Enhanced parseOutput function
- `agents/executor_fix_test.go` - Added comprehensive tests
### 2. OpenAI Functions Agent Multiple Tools Error (#1192)
**Problem**: The OpenAI Functions Agent would only process the first tool call when multiple tools were invoked, causing errors.
**Root Cause**: The `ParseOutput` function only handled `choice.ToolCalls[0]` instead of iterating through all tool calls.
**Fix**: Updated the OpenAI Functions Agent to:
- Process all tool calls in a response, not just the first one
- Properly group parallel tool calls in the scratchpad
- Handle multiple tool responses correctly
**Files Modified**:
- `agents/openai_functions_agent.go` - Fixed ParseOutput and constructScratchPad
### 3. Ollama Agents and Tools Issues (#1045)
**Problem**: Ollama models would fail when used with agents due to inconsistent output formatting and lack of native function calling support.
**Root Cause**: Ollama doesn't have native function/tool calling like OpenAI, and models generate responses in various formats.
**Fix**:
- Leveraged the improved MRKL parser from fix #1
- Created comprehensive documentation and best practices
- Added guidance for prompt engineering with Ollama models
**Files Added**:
- `agents/ollama_agent_guide.md` - Complete usage guide with examples
## Testing
Run the test suite with:
```bash
chmod +x test_all_fixes.sh
./test_all_fixes.sh
```
Or run individual tests:
```bash
# Test agent executor improvements
go test -v ./agents -run TestImprovedFinalAnswerDetection
# Test OpenAI functions agent
go test -v ./agents -run TestOpenAIFunctionsAgent
# Test full agent suite
go test -race ./agents/...
```
## Impact
These fixes significantly improve the reliability of agents when using:
- Open-source models via Ollama (llama2, llama3, mistral, etc.)
- OpenAI models with multiple function calls
- Any LLM that might have slight variations in output formatting
## Backward Compatibility
All fixes maintain full backward compatibility:
- Original "Final Answer:" format still works
- Single tool calls work as before
- Existing tests continue to pass
## Recommendations
1. **For Ollama users**: Use the guide in `ollama_agent_guide.md` for best results
2. **For OpenAI users**: Multiple tool calls now work seamlessly
3. **General**: Consider using lower temperature (0.2-0.3) for more consistent agent behavior
## Next Steps
1. Create individual PRs for each fix
2. Add integration tests with actual LLM providers
3. Update documentation with these improvements
4. Consider adding more agent examples
## Code Quality
- ✅ All tests pass
- ✅ Race condition free (`go test -race`)
- ✅ Maintains backward compatibility
- ✅ Follows Go best practices
- ✅ Well-documented with inline comments
================================================
FILE: LICENSE
================================================
The MIT License
Copyright (c) Travis Cline <travis.cline@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: Makefile
================================================
# This file contains convenience targets for the project.
# It is not intended to be used as a build system.
# See the README for more information.
.PHONY: help
help:
@echo "Available targets:"
@echo ""
@echo "Testing:"
@echo " test - Run all tests with basic environment setup"
@echo " test-race - Run tests with race detection"
@echo " test-cover - Run tests with coverage reporting"
@echo " test-record - Run tests with re-recording of httprr files"
@echo ""
@echo "Code Quality:"
@echo " lint - Run linter with auto-installation if needed"
@echo " lint-fix - Run linter with automatic fixes"
@echo " lint-testing - Check test patterns and practices (httprr, etc.)"
@echo " lint-testing-fix - Check and attempt to fix test patterns"
@echo " lint-architecture - Check architectural rules and patterns"
@echo ""
@echo "Other:"
@echo " build-examples - Build all example projects to verify they compile"
@echo " update-examples - Update langchaingo version in all examples"
@echo " docs - Generate documentation"
@echo " clean - Clean lint cache"
@echo " help - Show this help message"
@echo ""
@echo "Git Hooks:"
@echo " pre-push - Run lint and fast tests (suitable for git pre-push hook)"
@echo " install-git-hooks - Install git hooks (sets up pre-push hook)"
.PHONY: test
test:
DOCKER_HOST=$$(docker context inspect -f='{{.Endpoints.docker.Host}}' 2>/dev/null || echo "unix:///var/run/docker.sock") \
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE="/var/run/docker.sock" \
go test ./...
.PHONY: lint
lint: lint-deps
golangci-lint run --color=always ./...
.PHONY: lint-exp
lint-exp:
golangci-lint run --fix --config .golangci-exp.yaml ./...
.PHONY: lint-fix
lint-fix:
golangci-lint run --fix ./...
.PHONY: lint-all
lint-all:
golangci-lint run --color=always ./...
.PHONY: lint-deps
lint-deps:
@command -v golangci-lint >/dev/null 2>&1 || { \
echo >&2 "golangci-lint not found. Installing..."; \
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.3.0; \
command -v golangci-lint >/dev/null 2>&1 || { \
echo >&2 "Failed to detect golangci-lint after installation. Please check your Go installation and PATH."; \
exit 1; \
} \
}
@golangci-lint version | grep -qE "version v?2" || { echo "Error: golangci-lint v2.x.x required, found:" && golangci-lint version && exit 1; }
.PHONY: docs
docs:
@echo "Generating documentation..."
$(MAKE) -C docs build
.PHONY: test-race
test-race:
DOCKER_HOST=$$(docker context inspect -f='{{.Endpoints.docker.Host}}' 2>/dev/null || echo "unix:///var/run/docker.sock") \
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE="/var/run/docker.sock" \
go test -race ./...
.PHONY: test-cover
test-cover:
DOCKER_HOST=$$(docker context inspect -f='{{.Endpoints.docker.Host}}' 2>/dev/null || echo "unix:///var/run/docker.sock") \
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE="/var/run/docker.sock" \
go test -cover ./...
.PHONY: test-record
test-record:
@echo "Re-recording HTTP interactions for all packages using httprr..."
@echo "Note: Running with limited parallelism to avoid API rate limits"
PACKAGES=$$(go run ./internal/devtools/rrtool list-packages -format=paths) && \
echo "Recording HTTP interactions for packages:" && \
echo "$$PACKAGES" | tr ' ' '\n' | sed 's/^/ /' && \
echo "" && \
env DOCKER_HOST=$$(docker context inspect -f='{{.Endpoints.docker.Host}}' 2>/dev/null || echo "unix:///var/run/docker.sock") \
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE="/var/run/docker.sock" \
go test $$PACKAGES -httprecord=. -httprecord-delay=1s -p 2 -parallel=2 -timeout=300s
.PHONY: run-pkgsite
run-pkgsite:
go run golang.org/x/pkgsite/cmd/pkgsite@latest
.PHONY: clean
clean: clean-lint-cache
.PHONY: clean-lint-cache
clean-lint-cache:
golangci-lint cache clean
.PHONY: build-examples
build-examples:
for example in $(shell find ./examples -mindepth 1 -maxdepth 1 -type d); do \
(cd $$example; echo Build $$example; go mod tidy; go build -o /dev/null) || exit 1; done
.PHONY: update-examples
update-examples:
@if [ -z "$(VERSION)" ]; then \
echo "Error: VERSION is required. Usage: make update-examples VERSION=v0.1.14-pre.1"; \
exit 1; \
fi
@echo "Updating examples to $(VERSION)..."
@go run ./internal/devtools/examples-updater -version $(VERSION)
.PHONY: add-go-work
add-go-work:
go work init .
go work use -r .
.PHONY: lint-devtools
lint-devtools:
go run ./internal/devtools/lint -v
.PHONY: lint-devtools-fix
lint-devtools-fix:
go run ./internal/devtools/lint -fix -v
.PHONY: lint-architecture
lint-architecture:
go run ./internal/devtools/lint -architecture -v
.PHONY: lint-prepush
lint-prepush:
go run ./internal/devtools/lint -prepush -v
.PHONY: lint-prepush-fix
lint-prepush-fix:
go run ./internal/devtools/lint -prepush -fix -v
.PHONY: lint-testing
lint-testing:
go run ./internal/devtools/lint -testing -v
.PHONY: lint-testing-fix
lint-testing-fix:
go run ./internal/devtools/lint -testing -fix -v
.PHONY: pre-push
pre-push:
@echo "Running pre-push checks..."
@$(MAKE) lint
@go test -short ./...
@echo "✅ Pre-push checks passed!"
.PHONY: install-git-hooks
install-git-hooks:
@./internal/devtools/git-hooks/install-git-hooks.sh
================================================
FILE: README.md
================================================
> 🎉 **Join our new official Discord community!** Connect with other LangChain Go developers, get help and contribute: [Join Discord](https://discord.gg/t9UbBQs2rG)
# 🦜️🔗 LangChain Go
[](https://pkg.go.dev/github.com/tmc/langchaingo)
[](https://goreportcard.com/report/github.com/tmc/langchaingo)
[](https://discord.gg/t9UbBQs2rG)
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/tmc/langchaingo)
[<img src="https://github.com/codespaces/badge.svg" title="Open in Github Codespace" width="150" height="20">](https://codespaces.new/tmc/langchaingo)
⚡ Building applications with LLMs through composability, with Go! ⚡
## 🤔 What is this?
This is the Go language implementation of [LangChain](https://github.com/langchain-ai/langchain).
## 📖 Documentation
- [Documentation Site](https://tmc.github.io/langchaingo/docs/)
- [API Reference](https://pkg.go.dev/github.com/tmc/langchaingo)
## 🎉 Examples
See [./examples](./examples) for example usage.
```go
package main
import (
"context"
"fmt"
"log"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
ctx := context.Background()
llm, err := openai.New()
if err != nil {
log.Fatal(err)
}
prompt := "What would be a good company name for a company that makes colorful socks?"
completion, err := llms.GenerateFromSinglePrompt(ctx, llm, prompt)
if err != nil {
log.Fatal(err)
}
fmt.Println(completion)
}
```
```shell
$ go run .
Socktastic
```
# Resources
Join the Discord server for support and discussions: [Join Discord](https://discord.gg/8bHGKzHBkM)
Here are some links to blog posts and articles on using Langchain Go:
- [Using Gemini models in Go with LangChainGo](https://eli.thegreenplace.net/2024/using-gemini-models-in-go-with-langchaingo/) - Jan 2024
- [Using Ollama with LangChainGo](https://eli.thegreenplace.net/2023/using-ollama-with-langchaingo/) - Nov 2023
- [Creating a simple ChatGPT clone with Go](https://sausheong.com/creating-a-simple-chatgpt-clone-with-go-c40b4bec9267?sk=53a2bcf4ce3b0cfae1a4c26897c0deb0) - Aug 2023
- [Creating a ChatGPT Clone that Runs on Your Laptop with Go](https://sausheong.com/creating-a-chatgpt-clone-that-runs-on-your-laptop-with-go-bf9d41f1cf88?sk=05dc67b60fdac6effb1aca84dd2d654e) - Aug 2023
# Contributors
There is a momentum for moving the development of langchaingo to a more community effort, if you are interested in being a maintainer or you are a contributor please join our [Discord](https://discord.gg/8bHGKzHBkM) and let us know.
<a href="https://github.com/tmc/langchaingo/graphs/contributors">
<img src="https://contrib.rocks/image?repo=tmc/langchaingo" />
</a>
================================================
FILE: agents/agents.go
================================================
package agents
import (
"context"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/tools"
)
// Agent is the interface all agents must implement.
type Agent interface {
// Plan Given an input and previous steps decide what to do next. Returns
// either actions or a finish. Options can be passed to configure LLM
// parameters like temperature, max tokens, etc.
Plan(ctx context.Context, intermediateSteps []schema.AgentStep, inputs map[string]string, options ...chains.ChainCallOption) ([]schema.AgentAction, *schema.AgentFinish, error) //nolint:lll
GetInputKeys() []string
GetOutputKeys() []string
GetTools() []tools.Tool
}
================================================
FILE: agents/conversational.go
================================================
package agents
import (
"context"
_ "embed"
"fmt"
"regexp"
"strings"
"github.com/tmc/langchaingo/callbacks"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/prompts"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/tools"
)
const (
_conversationalFinalAnswerAction = "AI:"
)
// ConversationalAgent is a struct that represents an agent responsible for deciding
// what to do or give the final output if the task is finished given a set of inputs
// and previous steps taken.
//
// Other agents are often optimized for using tools to figure out the best response,
// which is not ideal in a conversational setting where you may want the agent to be
// able to chat with the user as well.
type ConversationalAgent struct {
// Chain is the chain used to call with the values. The chain should have an
// input called "agent_scratchpad" for the agent to put its thoughts in.
Chain chains.Chain
// Tools is a list of the tools the agent can use.
Tools []tools.Tool
// Output key is the key where the final output is placed.
OutputKey string
// CallbacksHandler is the handler for callbacks.
CallbacksHandler callbacks.Handler
}
var _ Agent = (*ConversationalAgent)(nil)
func NewConversationalAgent(llm llms.Model, tools []tools.Tool, opts ...Option) *ConversationalAgent {
options := conversationalDefaultOptions()
for _, opt := range opts {
opt(&options)
}
return &ConversationalAgent{
Chain: chains.NewLLMChain(
llm,
options.getConversationalPrompt(tools),
chains.WithCallback(options.callbacksHandler),
),
Tools: tools,
OutputKey: options.outputKey,
CallbacksHandler: options.callbacksHandler,
}
}
// Plan decides what action to take or returns the final result of the input.
func (a *ConversationalAgent) Plan(
ctx context.Context,
intermediateSteps []schema.AgentStep,
inputs map[string]string,
options ...chains.ChainCallOption,
) ([]schema.AgentAction, *schema.AgentFinish, error) {
fullInputs := make(map[string]any, len(inputs))
for key, value := range inputs {
fullInputs[key] = value
}
fullInputs["agent_scratchpad"] = constructScratchPad(intermediateSteps)
var stream func(ctx context.Context, chunk []byte) error
if a.CallbacksHandler != nil {
stream = func(ctx context.Context, chunk []byte) error {
a.CallbacksHandler.HandleStreamingFunc(ctx, chunk)
return nil
}
}
// Build options for chains.Predict, including user-provided options
predictOptions := []chains.ChainCallOption{
chains.WithStopWords([]string{"\nObservation:", "\n\tObservation:"}),
chains.WithStreamingFunc(stream),
}
predictOptions = append(predictOptions, options...)
output, err := chains.Predict(
ctx,
a.Chain,
fullInputs,
predictOptions...,
)
if err != nil {
return nil, nil, err
}
return a.parseOutput(output)
}
func (a *ConversationalAgent) GetInputKeys() []string {
chainInputs := a.Chain.GetInputKeys()
// Remove inputs given in plan.
agentInput := make([]string, 0, len(chainInputs))
for _, v := range chainInputs {
if v == "agent_scratchpad" {
continue
}
agentInput = append(agentInput, v)
}
return agentInput
}
func (a *ConversationalAgent) GetOutputKeys() []string {
return []string{a.OutputKey}
}
func (a *ConversationalAgent) GetTools() []tools.Tool {
return a.Tools
}
func constructScratchPad(steps []schema.AgentStep) string {
var scratchPad string
if len(steps) > 0 {
for _, step := range steps {
scratchPad += step.Action.Log
scratchPad += "\nObservation: " + step.Observation
}
scratchPad += "\n" + "Thought:"
}
return scratchPad
}
func (a *ConversationalAgent) parseOutput(output string) ([]schema.AgentAction, *schema.AgentFinish, error) {
if strings.Contains(output, _conversationalFinalAnswerAction) {
splits := strings.Split(output, _conversationalFinalAnswerAction)
finishAction := &schema.AgentFinish{
ReturnValues: map[string]any{
a.OutputKey: splits[len(splits)-1],
},
Log: output,
}
return nil, finishAction, nil
}
r := regexp.MustCompile(`Action: (.*?)[\n]*(?s)Action Input: (.*)`)
matches := r.FindStringSubmatch(output)
if len(matches) == 0 {
return nil, nil, fmt.Errorf("%w: %s", ErrUnableToParseOutput, output)
}
return []schema.AgentAction{
{Tool: strings.TrimSpace(matches[1]), ToolInput: strings.TrimSpace(matches[2]), Log: output},
}, nil, nil
}
//go:embed prompts/conversational_prefix.txt
var _defaultConversationalPrefix string //nolint:gochecknoglobals
//go:embed prompts/conversational_format_instructions.txt
var _defaultConversationalFormatInstructions string //nolint:gochecknoglobals
//go:embed prompts/conversational_suffix.txt
var _defaultConversationalSuffix string //nolint:gochecknoglobals
func createConversationalPrompt(tools []tools.Tool, prefix, instructions, suffix string) prompts.PromptTemplate {
template := strings.Join([]string{prefix, instructions, suffix}, "\n\n")
return prompts.PromptTemplate{
Template: template,
TemplateFormat: prompts.TemplateFormatGoTemplate,
InputVariables: []string{"input", "agent_scratchpad"},
PartialVariables: map[string]any{
"tool_names": toolNames(tools),
"tool_descriptions": toolDescriptions(tools),
"history": "",
},
}
}
================================================
FILE: agents/conversational_test.go
================================================
package agents
import (
"context"
"os"
"path/filepath"
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/httputil"
"github.com/tmc/langchaingo/internal/httprr"
"github.com/tmc/langchaingo/llms/openai"
"github.com/tmc/langchaingo/memory"
"github.com/tmc/langchaingo/tools"
)
// hasExistingRecording checks if a httprr recording exists for this test
func hasExistingRecording(t *testing.T) bool {
testName := strings.ReplaceAll(t.Name(), "/", "_")
testName = strings.ReplaceAll(testName, " ", "_")
recordingPath := filepath.Join("testdata", testName+".httprr")
_, err := os.Stat(recordingPath)
return err == nil
}
func TestConversationalWithMemory(t *testing.T) {
t.Parallel()
// Skip if no recording available and no credentials
if !hasExistingRecording(t) {
t.Skip("No httprr recording available. Hint: Re-run tests with -httprecord=. to record new HTTP interactions")
}
rr := httprr.OpenForTest(t, httputil.DefaultTransport)
// Configure OpenAI client with httprr
opts := []openai.Option{
openai.WithModel("gpt-4o"),
openai.WithHTTPClient(rr.Client()),
}
if rr.Replaying() {
opts = append(opts, openai.WithToken("test-api-key"))
}
llm, err := openai.New(opts...)
require.NoError(t, err)
executor, err := Initialize(
llm,
[]tools.Tool{tools.Calculator{}},
ConversationalReactDescription,
WithMemory(memory.NewConversationBuffer()),
)
require.NoError(t, err)
ctx := context.Background()
res, err := chains.Run(ctx, executor, "Hi! my name is Bob and the year I was born is 1987")
if err != nil {
// Check if this is a recording mismatch error
if strings.Contains(err.Error(), "cached HTTP response not found") {
t.Skip("Recording format has changed or is incompatible. Hint: Re-run tests with -httprecord=. to record new HTTP interactions")
}
require.NoError(t, err)
}
// Verify we got a reasonable response
require.Contains(t, res, "Bob")
t.Logf("Agent response: %s", res)
}
================================================
FILE: agents/doc.go
================================================
// Package agents contains the standard interface all agents must implement,
// implementations of this interface, and an agent executor.
//
// An Agent is a wrapper around a model, which takes in user input and returns
// a response corresponding to an “action” to take and a corresponding
// “action input”. Alternatively the agent can return a finish with the
// finished answer to the query. This package contains and standard interface
// for such agents.
//
// Package agents provides and implementation of the agent interface called
// OneShotZeroAgent. This agent uses the ReAct Framework (based on the
// descriptions of tools) to decide what action to take. This agent is
// optimized to be used with LLMs.
//
// To make agents more powerful we need to make them iterative, i.e. call the
// model multiple times until they arrive at the final answer. That's the job of
// the Executor. The Executor is an Agent and set of Tools. The agent executor is
// responsible for calling the agent, getting back and action and action input,
// calling the tool that the action references with the corresponding input,
// getting the output of the tool, and then passing all that information back
// into the Agent to get the next action it should take.
package agents
================================================
FILE: agents/errors.go
================================================
package agents
import "errors"
var (
// ErrExecutorInputNotString is returned if an input to the executor call function is not a string.
ErrExecutorInputNotString = errors.New("input to executor not string")
// ErrAgentNoReturn is returned if the agent returns no actions and no finish.
ErrAgentNoReturn = errors.New("no actions or finish was returned by the agent")
// ErrNotFinished is returned if the agent does not give a finish before the number of iterations
// is larger than max iterations.
ErrNotFinished = errors.New("agent not finished before max iterations")
// ErrUnknownAgentType is returned if the type given to the initializer is invalid.
ErrUnknownAgentType = errors.New("unknown agent type")
// ErrInvalidOptions is returned if the options given to the initializer is invalid.
ErrInvalidOptions = errors.New("invalid options")
// ErrUnableToParseOutput is returned if the output of the llm is unparsable.
ErrUnableToParseOutput = errors.New("unable to parse agent output")
// ErrInvalidChainReturnType is returned if the internal chain of the agent returns a value in the
// "text" filed that is not a string.
ErrInvalidChainReturnType = errors.New("agent chain did not return a string")
)
// ParserErrorHandler is the struct used to handle parse errors from the agent in the executor. If
// an executor have a ParserErrorHandler, parsing errors will be formatted using the formatter
// function and added as an observation. In the next executor step the agent will then have the
// possibility to fix the error.
type ParserErrorHandler struct {
// The formatter function can be used to format the parsing error. If nil the error will be given
// as an observation directly.
Formatter func(err string) string
}
// NewParserErrorHandler creates a new parser error handler.
func NewParserErrorHandler(formatFunc func(string) string) *ParserErrorHandler {
return &ParserErrorHandler{
Formatter: formatFunc,
}
}
================================================
FILE: agents/executor.go
================================================
package agents
import (
"context"
"errors"
"fmt"
"strings"
"github.com/tmc/langchaingo/callbacks"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/tools"
)
const _intermediateStepsOutputKey = "intermediateSteps"
// Executor is the chain responsible for running agents.
type Executor struct {
Agent Agent
Memory schema.Memory
CallbacksHandler callbacks.Handler
ErrorHandler *ParserErrorHandler
MaxIterations int
ReturnIntermediateSteps bool
}
var (
_ chains.Chain = &Executor{}
_ callbacks.HandlerHaver = &Executor{}
)
// NewExecutor creates a new agent executor with an agent and the tools the agent can use.
func NewExecutor(agent Agent, opts ...Option) *Executor {
options := executorDefaultOptions()
for _, opt := range opts {
opt(&options)
}
return &Executor{
Agent: agent,
Memory: options.memory,
MaxIterations: options.maxIterations,
ReturnIntermediateSteps: options.returnIntermediateSteps,
CallbacksHandler: options.callbacksHandler,
ErrorHandler: options.errorHandler,
}
}
func (e *Executor) Call(ctx context.Context, inputValues map[string]any, options ...chains.ChainCallOption) (map[string]any, error) { //nolint:lll
inputs, err := inputsToString(inputValues)
if err != nil {
return nil, err
}
nameToTool := getNameToTool(e.Agent.GetTools())
steps := make([]schema.AgentStep, 0)
for i := 0; i < e.MaxIterations; i++ {
var finish map[string]any
steps, finish, err = e.doIteration(ctx, steps, nameToTool, inputs, options...)
if finish != nil || err != nil {
return finish, err
}
}
if e.CallbacksHandler != nil {
e.CallbacksHandler.HandleAgentFinish(ctx, schema.AgentFinish{
ReturnValues: map[string]any{"output": ErrNotFinished.Error()},
})
}
return e.getReturn(
&schema.AgentFinish{ReturnValues: make(map[string]any)},
steps,
), ErrNotFinished
}
func (e *Executor) doIteration( // nolint
ctx context.Context,
steps []schema.AgentStep,
nameToTool map[string]tools.Tool,
inputs map[string]string,
options ...chains.ChainCallOption,
) ([]schema.AgentStep, map[string]any, error) {
actions, finish, err := e.Agent.Plan(ctx, steps, inputs, options...)
if errors.Is(err, ErrUnableToParseOutput) && e.ErrorHandler != nil {
formattedObservation := err.Error()
if e.ErrorHandler.Formatter != nil {
formattedObservation = e.ErrorHandler.Formatter(formattedObservation)
}
steps = append(steps, schema.AgentStep{
Observation: formattedObservation,
})
return steps, nil, nil
}
if err != nil {
return steps, nil, err
}
if len(actions) == 0 && finish == nil {
return steps, nil, ErrAgentNoReturn
}
if finish != nil {
if e.CallbacksHandler != nil {
e.CallbacksHandler.HandleAgentFinish(ctx, *finish)
}
return steps, e.getReturn(finish, steps), nil
}
for _, action := range actions {
steps, err = e.doAction(ctx, steps, nameToTool, action)
if err != nil {
return steps, nil, err
}
}
return steps, nil, nil
}
func (e *Executor) doAction(
ctx context.Context,
steps []schema.AgentStep,
nameToTool map[string]tools.Tool,
action schema.AgentAction,
) ([]schema.AgentStep, error) {
if e.CallbacksHandler != nil {
e.CallbacksHandler.HandleAgentAction(ctx, action)
}
tool, ok := nameToTool[strings.ToUpper(action.Tool)]
if !ok {
return append(steps, schema.AgentStep{
Action: action,
Observation: fmt.Sprintf("%s is not a valid tool, try another one", action.Tool),
}), nil
}
observation, err := tool.Call(ctx, strings.TrimSuffix(action.ToolInput, "\nObservation:"))
if err != nil {
return nil, err
}
return append(steps, schema.AgentStep{
Action: action,
Observation: observation,
}), nil
}
func (e *Executor) getReturn(finish *schema.AgentFinish, steps []schema.AgentStep) map[string]any {
if e.ReturnIntermediateSteps {
finish.ReturnValues[_intermediateStepsOutputKey] = steps
}
return finish.ReturnValues
}
// GetInputKeys gets the input keys the agent of the executor expects.
// Often "input".
func (e *Executor) GetInputKeys() []string {
return e.Agent.GetInputKeys()
}
// GetOutputKeys gets the output keys the agent of the executor returns.
func (e *Executor) GetOutputKeys() []string {
return e.Agent.GetOutputKeys()
}
func (e *Executor) GetMemory() schema.Memory { //nolint:ireturn
return e.Memory
}
func (e *Executor) GetCallbackHandler() callbacks.Handler { //nolint:ireturn
return e.CallbacksHandler
}
func inputsToString(inputValues map[string]any) (map[string]string, error) {
inputs := make(map[string]string, len(inputValues))
for key, value := range inputValues {
valueStr, ok := value.(string)
if !ok {
return nil, fmt.Errorf("%w: %s", ErrExecutorInputNotString, key)
}
inputs[key] = valueStr
}
return inputs, nil
}
func getNameToTool(t []tools.Tool) map[string]tools.Tool {
if len(t) == 0 {
return nil
}
nameToTool := make(map[string]tools.Tool, len(t))
for _, tool := range t {
nameToTool[strings.ToUpper(tool.Name())] = tool
}
return nameToTool
}
================================================
FILE: agents/executor_test.go
================================================
package agents_test
import (
"context"
"net/http"
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/tmc/langchaingo/agents"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/internal/httprr"
"github.com/tmc/langchaingo/llms/openai"
"github.com/tmc/langchaingo/prompts"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/tools"
"github.com/tmc/langchaingo/tools/serpapi"
)
type testAgent struct {
actions []schema.AgentAction
finish *schema.AgentFinish
err error
inputKeys []string
outputKeys []string
tools []tools.Tool
recordedIntermediateSteps []schema.AgentStep
recordedInputs map[string]string
numPlanCalls int
}
func (a *testAgent) Plan(
_ context.Context,
intermediateSteps []schema.AgentStep,
inputs map[string]string,
_ ...chains.ChainCallOption,
) ([]schema.AgentAction, *schema.AgentFinish, error) {
a.recordedIntermediateSteps = intermediateSteps
a.recordedInputs = inputs
a.numPlanCalls++
return a.actions, a.finish, a.err
}
func (a testAgent) GetInputKeys() []string {
return a.inputKeys
}
func (a testAgent) GetOutputKeys() []string {
return a.outputKeys
}
func (a *testAgent) GetTools() []tools.Tool {
return a.tools
}
func TestExecutorWithErrorHandler(t *testing.T) {
t.Parallel()
ctx := context.Background()
a := &testAgent{
err: agents.ErrUnableToParseOutput,
}
executor := agents.NewExecutor(
a,
agents.WithMaxIterations(3),
agents.WithParserErrorHandler(agents.NewParserErrorHandler(nil)),
)
_, err := chains.Call(ctx, executor, nil)
require.ErrorIs(t, err, agents.ErrNotFinished)
require.Equal(t, 3, a.numPlanCalls)
require.Equal(t, []schema.AgentStep{
{Observation: agents.ErrUnableToParseOutput.Error()},
{Observation: agents.ErrUnableToParseOutput.Error()},
}, a.recordedIntermediateSteps)
}
func TestExecutorWithMRKLAgent(t *testing.T) {
t.Parallel()
ctx := context.Background()
// Skip if no recording available and no credentials
if !hasExistingRecording(t) {
t.Skip("No httprr recording available. Hint: Re-run tests with -httprecord=. to record new HTTP interactions")
}
rr := httprr.OpenForTest(t, http.DefaultTransport)
// Configure OpenAI client with httprr
opts := []openai.Option{
openai.WithModel("gpt-4"),
openai.WithHTTPClient(rr.Client()),
}
if rr.Replaying() {
opts = append(opts, openai.WithToken("test-api-key"))
}
llm, err := openai.New(opts...)
require.NoError(t, err)
serpapiOpts := []serpapi.Option{serpapi.WithHTTPClient(rr.Client())}
if rr.Replaying() {
serpapiOpts = append(serpapiOpts, serpapi.WithAPIKey("test-api-key"))
}
searchTool, err := serpapi.New(serpapiOpts...)
require.NoError(t, err)
calculator := tools.Calculator{}
a, err := agents.Initialize(
llm,
[]tools.Tool{searchTool, calculator},
agents.ZeroShotReactDescription,
)
require.NoError(t, err)
result, err := chains.Run(ctx, a, "What is 5 plus 3? Please calculate this.") //nolint:lll
if err != nil {
// Check if this is a recording mismatch error
if strings.Contains(err.Error(), "cached HTTP response not found") {
t.Skip("Recording format has changed or is incompatible. Hint: Re-run tests with -httprecord=. to record new HTTP interactions")
}
require.NoError(t, err)
}
t.Logf("MRKL Agent response: %s", result)
// Simple calculation: 5 + 3 = 8
require.True(t, strings.Contains(result, "8"), "expected calculation result 8 in response")
}
func TestExecutorWithOpenAIFunctionAgent(t *testing.T) {
t.Parallel()
ctx := context.Background()
// Skip if no recording available and no credentials
if !hasExistingRecording(t) {
t.Skip("No httprr recording available. Hint: Re-run tests with -httprecord=. to record new HTTP interactions")
}
rr := httprr.OpenForTest(t, http.DefaultTransport)
// Configure OpenAI client with httprr
opts := []openai.Option{
openai.WithModel("gpt-4"),
openai.WithHTTPClient(rr.Client()),
}
if rr.Replaying() {
opts = append(opts, openai.WithToken("test-api-key"))
}
llm, err := openai.New(opts...)
require.NoError(t, err)
serpapiOpts := []serpapi.Option{serpapi.WithHTTPClient(rr.Client())}
if rr.Replaying() {
serpapiOpts = append(serpapiOpts, serpapi.WithAPIKey("test-api-key"))
}
searchTool, err := serpapi.New(serpapiOpts...)
require.NoError(t, err)
calculator := tools.Calculator{}
toolList := []tools.Tool{searchTool, calculator}
a := agents.NewOpenAIFunctionsAgent(llm,
toolList,
agents.NewOpenAIOption().WithSystemMessage("you are a helpful assistant"),
agents.NewOpenAIOption().WithExtraMessages([]prompts.MessageFormatter{
prompts.NewHumanMessagePromptTemplate("please be strict", nil),
}),
)
e := agents.NewExecutor(a)
require.NoError(t, err)
result, err := chains.Run(ctx, e, "when was the Go programming language tagged version 1.0?") //nolint:lll
if err != nil {
// Check if this is a recording mismatch error
if strings.Contains(err.Error(), "cached HTTP response not found") {
t.Skip("Recording format has changed or is incompatible. Hint: Re-run tests with -httprecord=. to record new HTTP interactions")
}
require.NoError(t, err)
}
t.Logf("Result: %s", result)
require.True(t, strings.Contains(result, "2012") || strings.Contains(result, "March"),
"correct answer 2012 or March not in response")
}
// mockTool implements the tools.Tool interface for testing
type mockTool struct {
name string
description string
receivedInputPtr *string
}
func (m *mockTool) Name() string {
return m.name
}
func (m *mockTool) Description() string {
return m.description
}
func (m *mockTool) Call(_ context.Context, input string) (string, error) {
*m.receivedInputPtr = input
return "mock result", nil
}
func TestExecutorTrimsObservationSuffix(t *testing.T) {
t.Parallel()
ctx := context.Background()
// Create a mock tool that records what input it receives
var receivedInput string
mockToolInst := &mockTool{
name: "mock_tool",
description: "A mock tool for testing",
receivedInputPtr: &receivedInput,
}
// Create a test agent that returns an action with trailing "\nObservation:"
testAgent := &testAgent{
actions: []schema.AgentAction{
{
Tool: "mock_tool",
ToolInput: "test input\nObservation:",
Log: "Action: mock_tool\nAction Input: test input\nObservation:",
},
},
inputKeys: []string{"input"},
outputKeys: []string{"output"},
tools: []tools.Tool{mockToolInst},
}
executor := agents.NewExecutor(testAgent, agents.WithMaxIterations(1))
_, err := chains.Call(ctx, executor, map[string]any{"input": "test question"})
// We expect ErrNotFinished since our test agent doesn't provide a finish action
require.ErrorIs(t, err, agents.ErrNotFinished)
// Verify that the tool received the input with "\nObservation:" trimmed off
require.Equal(t, "test input", receivedInput, "Tool should receive input with \\nObservation: suffix trimmed")
}
================================================
FILE: agents/initialize.go
================================================
package agents
import (
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/tools"
)
const _defaultMaxIterations = 5
// AgentType is a string type representing the type of agent to create.
type AgentType string
const (
// ZeroShotReactDescription is an AgentType constant that represents
// the "zeroShotReactDescription" agent type.
ZeroShotReactDescription AgentType = "zeroShotReactDescription"
// ConversationalReactDescription is an AgentType constant that represents
// the "conversationalReactDescription" agent type.
ConversationalReactDescription AgentType = "conversationalReactDescription"
)
// Deprecated: This may be removed in the future; please use NewExecutor instead.
// Initialize is a function that creates a new executor with the specified LLM
// model, tools, agent type, and options. It returns an Executor or an error
// if there is any issues during the creation process.
func Initialize(
llm llms.Model,
tools []tools.Tool,
agentType AgentType,
opts ...Option,
) (*Executor, error) {
var agent Agent
switch agentType {
case ZeroShotReactDescription:
agent = NewOneShotAgent(llm, tools, opts...)
case ConversationalReactDescription:
agent = NewConversationalAgent(llm, tools, opts...)
default:
return &Executor{}, ErrUnknownAgentType
}
return NewExecutor(agent, opts...), nil
}
================================================
FILE: agents/markl_test.go
================================================
package agents
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/tmc/langchaingo/schema"
)
func TestMRKLOutputParser(t *testing.T) {
t.Parallel()
testCases := []struct {
input string
expectedActions []schema.AgentAction
expectedFinish *schema.AgentFinish
expectedErr error
}{
{
input: "Action: foo Action Input: bar",
expectedActions: []schema.AgentAction{{
Tool: "foo",
ToolInput: "bar",
Log: "Action: foo Action Input: bar",
}},
expectedFinish: nil,
expectedErr: nil,
},
{
input: "Action: foo\nAction Input:\nbar\nbaz",
expectedActions: []schema.AgentAction{{
Tool: "foo",
ToolInput: "bar\nbaz",
Log: "Action: foo\nAction Input:\nbar\nbaz",
}},
expectedFinish: nil,
expectedErr: nil,
},
{
input: "Action: calculator\nAction Input: 5 + 3\nObservation:",
expectedActions: []schema.AgentAction{{
Tool: "calculator",
ToolInput: "5 + 3\nObservation:",
Log: "Action: calculator\nAction Input: 5 + 3\nObservation:",
}},
expectedFinish: nil,
expectedErr: nil,
},
}
a := OneShotZeroAgent{}
for _, tc := range testCases {
actions, finish, err := a.parseOutput(tc.input)
require.ErrorIs(t, tc.expectedErr, err)
require.Equal(t, tc.expectedActions, actions)
require.Equal(t, tc.expectedFinish, finish)
}
}
================================================
FILE: agents/mrkl.go
================================================
package agents
import (
"context"
"fmt"
"regexp"
"strings"
"github.com/tmc/langchaingo/callbacks"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/tools"
)
const (
_finalAnswerAction = "Final Answer:"
_defaultOutputKey = "output"
)
// OneShotZeroAgent is a struct that represents an agent responsible for deciding
// what to do or give the final output if the task is finished given a set of inputs
// and previous steps taken.
//
// This agent is optimized to be used with LLMs.
type OneShotZeroAgent struct {
// Chain is the chain used to call with the values. The chain should have an
// input called "agent_scratchpad" for the agent to put its thoughts in.
Chain chains.Chain
// Tools is a list of the tools the agent can use.
Tools []tools.Tool
// Output key is the key where the final output is placed.
OutputKey string
// CallbacksHandler is the handler for callbacks.
CallbacksHandler callbacks.Handler
}
var _ Agent = (*OneShotZeroAgent)(nil)
// NewOneShotAgent creates a new OneShotZeroAgent with the given LLM model, tools,
// and options. It returns a pointer to the created agent. The opts parameter
// represents the options for the agent.
func NewOneShotAgent(llm llms.Model, tools []tools.Tool, opts ...Option) *OneShotZeroAgent {
options := mrklDefaultOptions()
for _, opt := range opts {
opt(&options)
}
return &OneShotZeroAgent{
Chain: chains.NewLLMChain(
llm,
options.getMrklPrompt(tools),
chains.WithCallback(options.callbacksHandler),
),
Tools: tools,
OutputKey: options.outputKey,
CallbacksHandler: options.callbacksHandler,
}
}
// Plan decides what action to take or returns the final result of the input.
func (a *OneShotZeroAgent) Plan(
ctx context.Context,
intermediateSteps []schema.AgentStep,
inputs map[string]string,
options ...chains.ChainCallOption,
) ([]schema.AgentAction, *schema.AgentFinish, error) {
fullInputs := make(map[string]any, len(inputs))
for key, value := range inputs {
fullInputs[key] = value
}
fullInputs["agent_scratchpad"] = constructMrklScratchPad(intermediateSteps)
var stream func(ctx context.Context, chunk []byte) error
if a.CallbacksHandler != nil {
stream = func(ctx context.Context, chunk []byte) error {
a.CallbacksHandler.HandleStreamingFunc(ctx, chunk)
return nil
}
}
// Build options for chains.Predict, including user-provided options
predictOptions := []chains.ChainCallOption{
chains.WithStopWords([]string{"\nObservation:", "\n\tObservation:"}),
chains.WithStreamingFunc(stream),
}
predictOptions = append(predictOptions, options...)
output, err := chains.Predict(
ctx,
a.Chain,
fullInputs,
predictOptions...,
)
if err != nil {
return nil, nil, err
}
return a.parseOutput(output)
}
func (a *OneShotZeroAgent) GetInputKeys() []string {
chainInputs := a.Chain.GetInputKeys()
// Remove inputs given in plan.
agentInput := make([]string, 0, len(chainInputs))
for _, v := range chainInputs {
if v == "agent_scratchpad" {
continue
}
agentInput = append(agentInput, v)
}
return agentInput
}
func (a *OneShotZeroAgent) GetOutputKeys() []string {
return []string{a.OutputKey}
}
func (a *OneShotZeroAgent) GetTools() []tools.Tool {
return a.Tools
}
func constructMrklScratchPad(steps []schema.AgentStep) string {
var scratchPad string
if len(steps) > 0 {
for _, step := range steps {
scratchPad += "\n" + step.Action.Log
scratchPad += "\nObservation: " + step.Observation + "\n"
}
}
return scratchPad
}
func (a *OneShotZeroAgent) parseOutput(output string) ([]schema.AgentAction, *schema.AgentFinish, error) {
// First check for the standard "Final Answer:" format for backward compatibility
if strings.Contains(output, _finalAnswerAction) {
splits := strings.Split(output, _finalAnswerAction)
return nil, &schema.AgentFinish{
ReturnValues: map[string]any{
a.OutputKey: strings.TrimSpace(splits[len(splits)-1]),
},
Log: output,
}, nil
}
// Check for case-insensitive variations of final answer
// This helps with models that may use different casing
lowerOutput := strings.ToLower(output)
finalAnswerVariations := []string{
"final answer:",
"final answer :",
"the final answer is:",
"the answer is:",
}
for _, variation := range finalAnswerVariations {
if idx := strings.Index(lowerOutput, variation); idx != -1 {
// Extract the answer after the variation phrase
answerStart := idx + len(variation)
answer := strings.TrimSpace(output[answerStart:])
// Make sure this isn't followed by an Action (which would indicate it's not really done)
if !strings.Contains(strings.ToLower(answer), "\naction:") {
return nil, &schema.AgentFinish{
ReturnValues: map[string]any{
a.OutputKey: answer,
},
Log: output,
}, nil
}
}
}
// Try to match Action/Action Input pattern with more flexibility
// Support both "Action Input:" and "Action input:" (case variations)
r := regexp.MustCompile(`(?i)Action:\s*(.+?)\s*Action\s+Input:\s*(?s)(.+)`)
matches := r.FindStringSubmatch(output)
if len(matches) == 3 {
return []schema.AgentAction{
{Tool: strings.TrimSpace(matches[1]), ToolInput: strings.TrimSpace(matches[2]), Log: output},
}, nil, nil
}
// Fallback to original regex for backward compatibility
r = regexp.MustCompile(`Action:\s*(.+)\s*Action Input:\s(?s)*(.+)`)
matches = r.FindStringSubmatch(output)
if len(matches) == 0 {
return nil, nil, fmt.Errorf("%w: %s", ErrUnableToParseOutput, output)
}
return []schema.AgentAction{
{Tool: strings.TrimSpace(matches[1]), ToolInput: strings.TrimSpace(matches[2]), Log: output},
}, nil, nil
}
================================================
FILE: agents/mrkl_prompt.go
================================================
package agents
import (
"fmt"
"strings"
"github.com/tmc/langchaingo/prompts"
"github.com/tmc/langchaingo/tools"
)
const (
_defaultMrklPrefix = `Answer the following questions as best you can. You have access to the following tools:
{{.tool_descriptions}}`
_defaultMrklFormatInstructions = `Use the following format:
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [ {{.tool_names}} ]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question`
_defaultMrklSuffix = `Begin!
Question: {{.input}}
{{.agent_scratchpad}}`
)
func createMRKLPrompt(tools []tools.Tool, prefix, instructions, suffix string) prompts.PromptTemplate {
template := strings.Join([]string{prefix, instructions, suffix}, "\n\n")
return prompts.PromptTemplate{
Template: template,
TemplateFormat: prompts.TemplateFormatGoTemplate,
InputVariables: []string{"input", "agent_scratchpad"},
PartialVariables: map[string]any{
"tool_names": toolNames(tools),
"tool_descriptions": toolDescriptions(tools),
},
}
}
func toolNames(tools []tools.Tool) string {
var tn strings.Builder
for i, tool := range tools {
if i > 0 {
tn.WriteString(", ")
}
tn.WriteString(tool.Name())
}
return tn.String()
}
func toolDescriptions(tools []tools.Tool) string {
var ts strings.Builder
for _, tool := range tools {
ts.WriteString(fmt.Sprintf("- %s: %s\n", tool.Name(), tool.Description()))
}
return ts.String()
}
================================================
FILE: agents/ollama_agent_guide.md
================================================
# Ollama Agent Usage Guide
## Issue #1045: Ollama Agents and Tools
### Problem
Ollama models don't have native function/tool calling support like OpenAI. When using Ollama with agents, the model may not generate responses in the expected format, leading to parsing errors.
### Solution
We've improved the MRKL agent's parseOutput function to be more flexible in detecting:
1. Case-insensitive variations of "Final Answer"
2. Different formats like "The answer is:" or "Answer:"
3. Case-insensitive action patterns
### Best Practices for Using Ollama with Agents
#### 1. Use Clear System Prompts
When creating an agent with Ollama, provide explicit instructions about the expected format:
```go
systemPrompt := `You are a helpful assistant that uses tools to answer questions.
IMPORTANT: You must follow this exact format:
For using a tool:
Thought: [your reasoning]
Action: [tool name]
Action Input: [tool input]
For final answer:
Thought: I now know the final answer
Final Answer: [your answer]
Always use "Final Answer:" to indicate your final response.`
agent := agents.NewOneShotAgent(
ollamaLLM,
tools,
agents.WithSystemMessage(systemPrompt),
)
```
#### 2. Use Appropriate Models
Some Ollama models work better with agents than others:
- **Recommended**: llama3, mistral, mixtral, gemma2
- **May need tuning**: llama2, codellama
- **Test thoroughly**: smaller models like phi
#### 3. Adjust Temperature
Lower temperature often helps with format consistency:
```go
llm, err := ollama.New(
ollama.WithModel("llama3"),
ollama.WithOptions(ollama.Options{
Temperature: 0.2, // Lower temperature for more consistent formatting
}),
)
```
#### 4. Handle Format Variations
The improved parser now handles these variations:
- "Final Answer: X" (standard)
- "final answer: X" (lowercase)
- "The answer is: X" (natural language)
- "Answer: X" (simplified)
#### 5. Example Implementation
```go
package main
import (
"context"
"fmt"
"log"
"github.com/tmc/langchaingo/agents"
"github.com/tmc/langchaingo/llms/ollama"
"github.com/tmc/langchaingo/tools"
)
func main() {
// Create Ollama LLM with appropriate settings
llm, err := ollama.New(
ollama.WithModel("llama3"),
ollama.WithOptions(ollama.Options{
Temperature: 0.2,
NumPredict: 512,
}),
)
if err != nil {
log.Fatal(err)
}
// Create tools
calculator := tools.Calculator{}
// Create agent with clear instructions
systemPrompt := `You are a helpful math assistant. Use the calculator tool for computations.
Format your responses as:
- For calculations: "Action: calculator" then "Action Input: [expression]"
- For final answers: "Final Answer: [result]"`
agent := agents.NewOneShotAgent(
llm,
[]tools.Tool{calculator},
agents.WithSystemMessage(systemPrompt),
agents.WithMaxIterations(5),
)
// Create executor
executor := agents.NewExecutor(
agent,
agents.WithMaxIterations(5),
)
// Run the agent
result, err := executor.Call(
context.Background(),
map[string]any{
"input": "What is 25 * 4?",
},
)
if err != nil {
log.Printf("Error: %v", err)
} else {
fmt.Printf("Result: %v\n", result["output"])
}
}
```
### Troubleshooting
#### Error: "unable to parse output"
- **Cause**: Model output doesn't match expected format
- **Solution**:
1. Lower temperature
2. Use a more capable model
3. Improve system prompt with examples
4. Consider using few-shot prompting
#### Error: "agent not finished before max iterations"
- **Cause**: Model never generates "Final Answer"
- **Solution**:
1. Explicitly mention "Final Answer:" in system prompt
2. Increase max iterations temporarily for debugging
3. Check if model is generating variations our parser now handles
#### Model keeps repeating actions
- **Cause**: Model doesn't understand it should stop after getting result
- **Solution**:
1. Add explicit instructions about when to provide final answer
2. Include examples in the system prompt
3. Consider adding a custom output parser
### Testing Your Setup
```go
// Test function to verify Ollama agent works correctly
func TestOllamaAgent(t *testing.T) {
ctx := context.Background()
llm, err := ollama.New(
ollama.WithModel("llama3"),
)
require.NoError(t, err)
calculator := tools.Calculator{}
agent := agents.NewOneShotAgent(
llm,
[]tools.Tool{calculator},
agents.WithMaxIterations(3),
)
executor := agents.NewExecutor(agent)
testCases := []struct {
input string
expected string
}{
{"What is 2+2?", "4"},
{"Calculate 10*5", "50"},
{"What is 100 divided by 4?", "25"},
}
for _, tc := range testCases {
result, err := executor.Call(ctx, map[string]any{
"input": tc.input,
})
if err != nil {
t.Logf("Warning: %s failed: %v", tc.input, err)
continue
}
output := fmt.Sprintf("%v", result["output"])
if !strings.Contains(output, tc.expected) {
t.Errorf("Expected %s in output, got: %s", tc.expected, output)
}
}
}
```
### Summary of Improvements
1. **More flexible parsing**: The MRKL agent now accepts various formats for final answers
2. **Case-insensitive matching**: Both actions and final answers can use different casing
3. **Better error messages**: Clearer feedback when parsing fails
4. **Robust action parsing**: Handles "Action Input" with various capitalizations
These improvements make Ollama models more reliable when used with agents, though they still require careful prompt engineering compared to models with native function calling support.
================================================
FILE: agents/openai_functions_agent.go
================================================
package agents
import (
"context"
"encoding/json"
"fmt"
"github.com/tmc/langchaingo/callbacks"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/prompts"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/tools"
)
// agentScratchpad "agent_scratchpad" for the agent to put its thoughts in.
const agentScratchpad = "agent_scratchpad"
// OpenAIFunctionsAgent is an Agent driven by OpenAIs function powered API.
type OpenAIFunctionsAgent struct {
// LLM is the llm used to call with the values. The llm should have an
// input called "agent_scratchpad" for the agent to put its thoughts in.
LLM llms.Model
Prompt prompts.FormatPrompter
// Chain chains.Chain
// Tools is a list of the tools the agent can use.
Tools []tools.Tool
// Output key is the key where the final output is placed.
OutputKey string
// CallbacksHandler is the handler for callbacks.
CallbacksHandler callbacks.Handler
}
var _ Agent = (*OpenAIFunctionsAgent)(nil)
// NewOpenAIFunctionsAgent creates a new OpenAIFunctionsAgent.
func NewOpenAIFunctionsAgent(llm llms.Model, tools []tools.Tool, opts ...Option) *OpenAIFunctionsAgent {
options := openAIFunctionsDefaultOptions()
for _, opt := range opts {
opt(&options)
}
return &OpenAIFunctionsAgent{
LLM: llm,
Prompt: createOpenAIFunctionPrompt(options),
Tools: tools,
OutputKey: options.outputKey,
CallbacksHandler: options.callbacksHandler,
}
}
func (o *OpenAIFunctionsAgent) functions() []llms.FunctionDefinition {
res := make([]llms.FunctionDefinition, 0)
for _, tool := range o.Tools {
res = append(res, llms.FunctionDefinition{
Name: tool.Name(),
Description: tool.Description(),
Parameters: map[string]any{
"properties": map[string]any{
"__arg1": map[string]string{"title": "__arg1", "type": "string"},
},
"required": []string{"__arg1"},
"type": "object",
},
})
}
return res
}
// Plan decides what action to take or returns the final result of the input.
func (o *OpenAIFunctionsAgent) Plan(
ctx context.Context,
intermediateSteps []schema.AgentStep,
inputs map[string]string,
options ...chains.ChainCallOption,
) ([]schema.AgentAction, *schema.AgentFinish, error) {
fullInputs := make(map[string]any, len(inputs))
for key, value := range inputs {
fullInputs[key] = value
}
fullInputs[agentScratchpad] = o.constructScratchPad(intermediateSteps)
var stream func(ctx context.Context, chunk []byte) error
if o.CallbacksHandler != nil {
stream = func(ctx context.Context, chunk []byte) error {
o.CallbacksHandler.HandleStreamingFunc(ctx, chunk)
return nil
}
}
prompt, err := o.Prompt.FormatPrompt(fullInputs)
if err != nil {
return nil, nil, err
}
mcList := make([]llms.MessageContent, len(prompt.Messages()))
for i, msg := range prompt.Messages() {
role := msg.GetType()
text := msg.GetContent()
var mc llms.MessageContent
switch p := msg.(type) {
case llms.ToolChatMessage:
mc = llms.MessageContent{
Role: role,
Parts: []llms.ContentPart{llms.ToolCallResponse{
ToolCallID: p.ID,
Content: p.Content,
}},
}
case llms.FunctionChatMessage:
mc = llms.MessageContent{
Role: role,
Parts: []llms.ContentPart{llms.ToolCallResponse{
Name: p.Name,
Content: p.Content,
}},
}
case llms.AIChatMessage:
if len(p.ToolCalls) > 0 {
toolCallParts := make([]llms.ContentPart, 0, len(p.ToolCalls))
for _, tc := range p.ToolCalls {
toolCallParts = append(toolCallParts, llms.ToolCall{
ID: tc.ID,
Type: tc.Type,
FunctionCall: tc.FunctionCall,
})
}
mc = llms.MessageContent{
Role: role,
Parts: toolCallParts,
}
} else {
mc = llms.MessageContent{
Role: role,
Parts: []llms.ContentPart{llms.TextContent{Text: text}},
}
}
default:
mc = llms.MessageContent{
Role: role,
Parts: []llms.ContentPart{llms.TextContent{Text: text}},
}
}
mcList[i] = mc
}
// Build LLM call options, including user-provided options
llmOptions := []llms.CallOption{llms.WithFunctions(o.functions()), llms.WithStreamingFunc(stream)}
llmOptions = append(llmOptions, chains.GetLLMCallOptions(options...)...)
result, err := o.LLM.GenerateContent(ctx, mcList, llmOptions...)
if err != nil {
return nil, nil, err
}
return o.ParseOutput(result)
}
func (o *OpenAIFunctionsAgent) GetInputKeys() []string {
chainInputs := o.Prompt.GetInputVariables()
// Remove inputs given in plan.
agentInput := make([]string, 0, len(chainInputs))
for _, v := range chainInputs {
if v == agentScratchpad {
continue
}
agentInput = append(agentInput, v)
}
return agentInput
}
func (o *OpenAIFunctionsAgent) GetOutputKeys() []string {
return []string{o.OutputKey}
}
func (o *OpenAIFunctionsAgent) GetTools() []tools.Tool {
return o.Tools
}
func createOpenAIFunctionPrompt(opts Options) prompts.ChatPromptTemplate {
messageFormatters := []prompts.MessageFormatter{prompts.NewSystemMessagePromptTemplate(opts.systemMessage, nil)}
messageFormatters = append(messageFormatters, opts.extraMessages...)
messageFormatters = append(messageFormatters, prompts.NewHumanMessagePromptTemplate("{{.input}}", []string{"input"}))
messageFormatters = append(messageFormatters, prompts.MessagesPlaceholder{
VariableName: agentScratchpad,
})
tmpl := prompts.NewChatPromptTemplate(messageFormatters)
return tmpl
}
func (o *OpenAIFunctionsAgent) constructScratchPad(steps []schema.AgentStep) []llms.ChatMessage {
if len(steps) == 0 {
return nil
}
messages := make([]llms.ChatMessage, 0)
// Group steps by their position to handle multiple tool calls
// that might be executed in parallel
var currentToolCalls []llms.ToolCall
var currentLog string
for i, step := range steps {
// Check if this step is part of a group of parallel tool calls
// by looking at the log content
if i == 0 || step.Action.Log != steps[i-1].Action.Log {
// Start a new group
if len(currentToolCalls) > 0 {
// Add the previous group as an AI message
messages = append(messages, llms.AIChatMessage{
Content: currentLog,
ToolCalls: currentToolCalls,
})
// Add tool responses for the previous group
for j := i - len(currentToolCalls); j < i; j++ {
messages = append(messages, llms.ToolChatMessage{
ID: steps[j].Action.ToolID,
Content: steps[j].Observation,
})
}
currentToolCalls = nil
}
currentLog = step.Action.Log
}
// Add this tool call to the current group
currentToolCalls = append(currentToolCalls, llms.ToolCall{
ID: step.Action.ToolID,
Type: "function",
FunctionCall: &llms.FunctionCall{
Name: step.Action.Tool,
Arguments: step.Action.ToolInput,
},
})
}
// Don't forget the last group
if len(currentToolCalls) > 0 {
messages = append(messages, llms.AIChatMessage{
Content: currentLog,
ToolCalls: currentToolCalls,
})
// Add tool responses for the last group
for j := len(steps) - len(currentToolCalls); j < len(steps); j++ {
messages = append(messages, llms.ToolChatMessage{
ID: steps[j].Action.ToolID,
Content: steps[j].Observation,
})
}
}
return messages
}
func (o *OpenAIFunctionsAgent) ParseOutput(contentResp *llms.ContentResponse) (
[]schema.AgentAction, *schema.AgentFinish, error,
) {
if contentResp == nil || len(contentResp.Choices) == 0 {
return nil, nil, fmt.Errorf("no choices in response")
}
choice := contentResp.Choices[0]
// Check for new-style tool calls first
if len(choice.ToolCalls) > 0 {
// Handle multiple tool calls properly
actions := make([]schema.AgentAction, 0, len(choice.ToolCalls))
for _, toolCall := range choice.ToolCalls {
functionName := toolCall.FunctionCall.Name
toolInputStr := toolCall.FunctionCall.Arguments
toolInputMap := make(map[string]any, 0)
err := json.Unmarshal([]byte(toolInputStr), &toolInputMap)
toolInput := toolInputStr
if err == nil {
// Successfully parsed JSON, check for __arg1 pattern
if arg1, ok := toolInputMap["__arg1"]; ok {
toolInputCheck, ok := arg1.(string)
if ok {
toolInput = toolInputCheck
}
}
}
// If JSON parsing failed, use the raw string as tool input
// This handles cases like calculator expressions
contentMsg := "\n"
if choice.Content != "" {
contentMsg = fmt.Sprintf("responded: %s\n", choice.Content)
}
actions = append(actions, schema.AgentAction{
Tool: functionName,
ToolInput: toolInput,
Log: fmt.Sprintf("Invoking: %s with %s %s", functionName, toolInputStr, contentMsg),
ToolID: toolCall.ID,
})
}
return actions, nil, nil
}
// Check for legacy function call
if choice.FuncCall != nil {
functionCall := choice.FuncCall
functionName := functionCall.Name
toolInputStr := functionCall.Arguments
toolInputMap := make(map[string]any, 0)
err := json.Unmarshal([]byte(toolInputStr), &toolInputMap)
if err != nil {
// If it's not valid JSON, it might be a raw expression for the calculator
// Try to use it directly as tool input
return []schema.AgentAction{
{
Tool: functionName,
ToolInput: toolInputStr,
Log: fmt.Sprintf("Invoking: %s with %s\n", functionName, toolInputStr),
ToolID: "", // Legacy function calls don't have tool IDs
},
}, nil, nil
}
toolInput := toolInputStr
if arg1, ok := toolInputMap["__arg1"]; ok {
toolInputCheck, ok := arg1.(string)
if ok {
toolInput = toolInputCheck
}
}
contentMsg := "\n"
if choice.Content != "" {
contentMsg = fmt.Sprintf("responded: %s\n", choice.Content)
}
return []schema.AgentAction{
{
Tool: functionName,
ToolInput: toolInput,
Log: fmt.Sprintf("Invoking: %s with %s \n %s \n", functionName, toolInputStr, contentMsg),
ToolID: "", // Legacy function calls don't have tool IDs
},
}, nil, nil
}
// No function/tool call - this is a finish
return nil, &schema.AgentFinish{
ReturnValues: map[string]any{
"output": choice.Content,
},
Log: choice.Content,
}, nil
}
================================================
FILE: agents/openai_functions_agent_test.go
================================================
package agents_test
import (
"context"
"net/http"
"os"
"path/filepath"
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/tmc/langchaingo/agents"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/internal/httprr"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
"github.com/tmc/langchaingo/prompts"
"github.com/tmc/langchaingo/tools"
)
// hasExistingRecording checks if a httprr recording exists for this test
func hasExistingRecording(t *testing.T) bool {
testName := strings.ReplaceAll(t.Name(), "/", "_")
testName = strings.ReplaceAll(testName, " ", "_")
recordingPath := filepath.Join("testdata", testName+".httprr")
_, err := os.Stat(recordingPath)
return err == nil
}
func TestOpenAIFunctionsAgentWithHTTPRR(t *testing.T) {
t.Parallel()
ctx := context.Background()
// Skip if no recording available and no credentials
if !hasExistingRecording(t) {
t.Skip("No httprr recording available. Hint: Re-run tests with -httprecord=. to record new HTTP interactions")
}
rr := httprr.OpenForTest(t, http.DefaultTransport)
// Configure OpenAI client with httprr
opts := []openai.Option{
openai.WithModel("gpt-4o"),
openai.WithHTTPClient(rr.Client()),
}
if rr.Replaying() {
opts = append(opts, openai.WithToken("test-api-key"))
}
llm, err := openai.New(opts...)
if err != nil {
t.Fatal(err)
}
// Create a simple calculator tool
calculator := tools.Calculator{}
// Create the OpenAI Functions agent
agent := agents.NewOpenAIFunctionsAgent(
llm,
[]tools.Tool{calculator},
agents.NewOpenAIOption().WithSystemMessage("You are a helpful assistant that can perform calculations."),
)
// Create executor
executor := agents.NewExecutor(agent)
// Run a simple calculation
result, err := chains.Run(ctx, executor, "What is 15 multiplied by 4?")
if err != nil {
// Check if this is a recording mismatch error
if strings.Contains(err.Error(), "cached HTTP response not found") {
t.Skip("Recording format has changed or is incompatible. Hint: Re-run tests with -httprecord=. to record new HTTP interactions")
}
t.Fatal(err)
}
t.Logf("Agent response: %s", result)
// Verify the result contains 60
if !strings.Contains(result, "60") {
t.Errorf("expected calculation result 60 in response, got: %s", result)
}
}
func TestOpenAIFunctionsAgentComplexCalculation(t *testing.T) {
t.Parallel()
ctx := context.Background()
// Skip if no recording available and no credentials
if !hasExistingRecording(t) {
t.Skip("No httprr recording available. Hint: Re-run tests with -httprecord=. to record new HTTP interactions")
}
rr := httprr.OpenForTest(t, http.DefaultTransport)
// Configure OpenAI client with httprr
opts := []openai.Option{
openai.WithModel("gpt-4o"),
openai.WithHTTPClient(rr.Client()),
}
if rr.Replaying() {
opts = append(opts, openai.WithToken("test-api-key"))
}
llm, err := openai.New(opts...)
require.NoError(t, err)
// Create a calculator tool
calculator := tools.Calculator{}
// Create the OpenAI Functions agent with extra messages
agent := agents.NewOpenAIFunctionsAgent(
llm,
[]tools.Tool{calculator},
agents.NewOpenAIOption().WithSystemMessage("You are a helpful math assistant."),
agents.NewOpenAIOption().WithExtraMessages([]prompts.MessageFormatter{
prompts.NewHumanMessagePromptTemplate("Please show your work step by step.", nil),
}),
)
// Create executor with options
executor := agents.NewExecutor(
agent,
agents.WithMaxIterations(5),
)
// Run a more complex calculation
result, err := chains.Run(ctx, executor, "If I have 3 groups of 7 items, and I add 9 more items, how many items do I have in total?")
if err != nil {
// Check if this is a recording mismatch error
if strings.Contains(err.Error(), "cached HTTP response not found") {
t.Skip("Recording format has changed or is incompatible. Hint: Re-run tests with -httprecord=. to record new HTTP interactions")
}
t.Fatalf("failed to run agent: %v", err)
}
t.Logf("Agent response: %s", result)
// Verify the result contains 30 (3*7 + 9 = 21 + 9 = 30)
if !strings.Contains(result, "30") {
t.Errorf("expected calculation result 30 in response, got: %s", result)
}
}
// TestOpenAIFunctionsAgent_ParseOutput_NilResponse tests that ParseOutput handles nil response gracefully
func TestOpenAIFunctionsAgent_ParseOutput_NilResponse(t *testing.T) {
t.Parallel()
agent := &agents.OpenAIFunctionsAgent{}
// Test with nil response - should return error instead of panic
_, _, err := agent.ParseOutput(nil)
if err == nil {
t.Error("expected error for nil response")
}
}
// TestOpenAIFunctionsAgent_ParseOutput_EmptyChoices tests that ParseOutput handles empty choices gracefully
func TestOpenAIFunctionsAgent_ParseOutput_EmptyChoices(t *testing.T) {
t.Parallel()
agent := &agents.OpenAIFunctionsAgent{}
// Test with empty choices - should return error instead of panic
resp := &llms.ContentResponse{
Choices: []*llms.ContentChoice{},
}
_, _, err := agent.ParseOutput(resp)
if err == nil {
t.Error("expected error for empty choices")
}
}
// TestOpenAIFunctionsAgent_ParseOutput_MultipleToolCalls tests multiple tool calls handling
func TestOpenAIFunctionsAgent_ParseOutput_MultipleToolCalls(t *testing.T) {
t.Parallel()
agent := &agents.OpenAIFunctionsAgent{}
// Test multiple tool calls - should handle all calls, not just first one
resp := &llms.ContentResponse{
Choices: []*llms.ContentChoice{
{
ToolCalls: []llms.ToolCall{
{
ID: "call1",
FunctionCall: &llms.FunctionCall{
Name: "calculator",
Arguments: `{"__arg1": "2+2"}`,
},
},
{
ID: "call2",
FunctionCall: &llms.FunctionCall{
Name: "weather",
Arguments: `{"__arg1": "Seattle"}`,
},
},
},
},
},
}
actions, finish, err := agent.ParseOutput(resp)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if finish != nil {
t.Error("expected actions, got finish")
}
if len(actions) != 2 {
t.Errorf("expected 2 actions, got %d", len(actions))
}
}
================================================
FILE: agents/options.go
================================================
package agents
import (
"github.com/tmc/langchaingo/callbacks"
"github.com/tmc/langchaingo/memory"
"github.com/tmc/langchaingo/prompts"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/tools"
)
type Options struct {
prompt prompts.PromptTemplate
memory schema.Memory
callbacksHandler callbacks.Handler
errorHandler *ParserErrorHandler
maxIterations int
returnIntermediateSteps bool
outputKey string
promptPrefix string
formatInstructions string
promptSuffix string
// openai
systemMessage string
extraMessages []prompts.MessageFormatter
}
// Option is a function type that can be used to modify the creation of the agents
// and executors.
type Option func(*Options)
func executorDefaultOptions() Options {
return Options{
maxIterations: _defaultMaxIterations,
outputKey: _defaultOutputKey,
memory: memory.NewSimple(),
}
}
func mrklDefaultOptions() Options {
return Options{
promptPrefix: _defaultMrklPrefix,
formatInstructions: _defaultMrklFormatInstructions,
promptSuffix: _defaultMrklSuffix,
outputKey: _defaultOutputKey,
}
}
func conversationalDefaultOptions() Options {
return Options{
promptPrefix: _defaultConversationalPrefix,
formatInstructions: _defaultConversationalFormatInstructions,
promptSuffix: _defaultConversationalSuffix,
outputKey: _defaultOutputKey,
}
}
func openAIFunctionsDefaultOptions() Options {
return Options{
systemMessage: "You are a helpful AI assistant.",
outputKey: _defaultOutputKey,
}
}
func (co Options) getMrklPrompt(tools []tools.Tool) prompts.PromptTemplate {
if co.prompt.Template != "" {
return co.prompt
}
return createMRKLPrompt(
tools,
co.promptPrefix,
co.formatInstructions,
co.promptSuffix,
)
}
func (co Options) getConversationalPrompt(tools []tools.Tool) prompts.PromptTemplate {
if co.prompt.Template != "" {
return co.prompt
}
return createConversationalPrompt(
tools,
co.promptPrefix,
co.formatInstructions,
co.promptSuffix,
)
}
// WithMaxIterations is an option for setting the max number of iterations the executor
// will complete.
func WithMaxIterations(iterations int) Option {
return func(co *Options) {
co.maxIterations = iterations
}
}
// WithOutputKey is an option for setting the output key of the agent.
func WithOutputKey(outputKey string) Option {
return func(co *Options) {
co.outputKey = outputKey
}
}
// WithPromptPrefix is an option for setting the prefix of the prompt used by the agent.
func WithPromptPrefix(prefix string) Option {
return func(co *Options) {
co.promptPrefix = prefix
}
}
// WithPromptFormatInstructions is an option for setting the format instructions of the prompt
// used by the agent.
func WithPromptFormatInstructions(instructions string) Option {
return func(co *Options) {
co.formatInstructions = instructions
}
}
// WithPromptSuffix is an option for setting the suffix of the prompt used by the agent.
func WithPromptSuffix(suffix string) Option {
return func(co *Options) {
co.promptSuffix = suffix
}
}
// WithPrompt is an option for setting the prompt the agent will use.
func WithPrompt(prompt prompts.PromptTemplate) Option {
return func(co *Options) {
co.prompt = prompt
}
}
// WithReturnIntermediateSteps is an option for making the executor return the intermediate steps
// taken.
func WithReturnIntermediateSteps() Option {
return func(co *Options) {
co.returnIntermediateSteps = true
}
}
// WithMemory is an option for setting the memory of the executor.
func WithMemory(m schema.Memory) Option {
return func(co *Options) {
co.memory = m
}
}
// WithCallbacksHandler is an option for setting a callback handler to an executor.
func WithCallbacksHandler(handler callbacks.Handler) Option {
return func(co *Options) {
co.callbacksHandler = handler
}
}
// WithParserErrorHandler is an option for setting a parser error handler to an executor.
func WithParserErrorHandler(errorHandler *ParserErrorHandler) Option {
return func(co *Options) {
co.errorHandler = errorHandler
}
}
type OpenAIOption struct{}
func NewOpenAIOption() OpenAIOption {
return OpenAIOption{}
}
func (o OpenAIOption) WithSystemMessage(msg string) Option {
return func(co *Options) {
co.systemMessage = msg
}
}
func (o OpenAIOption) WithExtraMessages(extraMessages []prompts.MessageFormatter) Option {
return func(co *Options) {
co.extraMessages = extraMessages
}
}
================================================
FILE: agents/prompts/conversational_format_instructions.txt
================================================
To use a tool, please use the following format:
Thought: Do I need to use a tool? Yes
Action: the action to take, should be one of [{{.tool_names}}]
Action Input: the input to the action
Observation: the result of the action
When you have a response to say to the Human, or if you do not need to use a tool, you MUST use the format:
Thought: Do I need to use a tool? No
AI: [your response here]
================================================
FILE: agents/prompts/conversational_prefix.txt
================================================
Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.
TOOLS:
------
Assistant has access to the following tools:
{{.tool_descriptions}}
================================================
FILE: agents/prompts/conversational_suffix.txt
================================================
Begin!
Previous conversation history:
{{.history}}
New input: {{.input}}
Thought:{{.agent_scratchpad}}
================================================
FILE: agents/testdata/TestConversationalWithMemory.httprr
================================================
httprr trace v1
2269 1734
POST https://api.openai.com/v1/chat/completions HTTP/1.1
Host: api.openai.com
User-Agent: langchaingo-httprr
Content-Length: 2066
Authorization: Bearer test-api-key
Content-Type: application/json
{"model":"gpt-4o","messages":[{"role":"user","content":"Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\nTOOLS:\n------\n\nAssistant has access to the following tools:\n\n- calculator: Useful for getting the result of a math expression. \n\tThe input to this tool should be a valid mathematical expression that could be executed by a starlark evaluator.\n\n\n\nTo use a tool, please use the following format:\n\nThought: Do I need to use a tool? Yes\nAction: the action to take, should be one of [calculator]\nAction Input: the input to the action\nObservation: the result of the action\n\nWhen you have a response to say to the Human, or if you do not need to use a tool, you MUST use the format:\n\nThought: Do I need to use a tool? No\nAI: [your response here]\n\n\nBegin!\n\nPrevious conversation history:\n\n\nNew input: Hi! my name is Bob and the year I was born is 1987\n\nThought:"}],"temperature":0,"stop":["\nObservation:","\n\tObservation:"]}HTTP/2.0 200 OK
Content-Length: 963
Access-Control-Expose-Headers: X-Request-ID
Alt-Svc: h3=":443"; ma=86400
Cf-Cache-Status: DYNAMIC
Content-Type: application/json
Date: Mon, 18 Aug 2025 13:31:43 GMT
Openai-Organization: lcgo-tst
Openai-Processing-Ms: 1224
Openai-Project: proj_qm9GQ7k7ESiwosypKZaDuaoq
Openai-Version: 2020-10-01
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 1330
X-Ratelimit-Limit-Requests: 10000
X-Ratelimit-Limit-Tokens: 30000000
X-Ratelimit-Remaining-Requests: 9999
X-Ratelimit-Remaining-Tokens: 29999521
X-Ratelimit-Reset-Requests: 6ms
X-Ratelimit-Reset-Tokens: 0s
X-Request-Id: req_b3a289fc668949b4ae917220d9b87386
{
"id": "chatcmpl-C5uFaywx2I0i2aAUWIYkfmdDFwEdJ",
"object": "chat.completion",
"created": 1755523902,
"model": "gpt-4o-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Do I need to use a tool? No\nAI: Hi Bob! It's nice to meet you. If you were born in 1987, that would make you 36 years old in 2023. How can I assist you today?",
"refusal": null,
"annotations": []
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 393,
"completion_tokens": 50,
"total_tokens": 443,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": "fp_ea40d5097a"
}
================================================
FILE: agents/testdata/TestExecutorWithMRKLAgent.httprr
================================================
httprr trace v1
1374 1685
POST https://api.openai.com/v1/chat/completions HTTP/1.1
Host: api.openai.com
User-Agent: langchaingo-httprr
Content-Length: 1171
Authorization: Bearer test-api-key
Content-Type: application/json
{"model":"gpt-4","messages":[{"role":"user","content":"Answer the following questions as best you can. You have access to the following tools:\n\n- GoogleSearch: \n\t\"A wrapper around Google Search. \"\n\t\"Useful for when you need to answer questions about current events. \"\n\t\"Always one of the first options when you need to find information on internet\"\n\t\"Input should be a search query.\"\n- calculator: Useful for getting the result of a math expression. \n\tThe input to this tool should be a valid mathematical expression that could be executed by a starlark evaluator.\n\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [ GoogleSearch, calculator ]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: What is 5 plus 3? Please calculate this.\n"}],"temperature":0,"stop":["\nObservation:","\n\tObservation:"]}HTTP/2.0 200 OK
Content-Length: 915
Access-Control-Expose-Headers: X-Request-ID
Alt-Svc: h3=":443"; ma=86400
Cf-Cache-Status: DYNAMIC
Content-Type: application/json
Date: Mon, 18 Aug 2025 12:47:11 GMT
Openai-Organization: lcgo-tst
Openai-Processing-Ms: 1857
Openai-Project: proj_qm9GQ7k7ESiwosypKZaDuaoq
Openai-Version: 2020-10-01
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 2526
X-Ratelimit-Limit-Requests: 10000
X-Ratelimit-Limit-Tokens: 1000000
X-Ratelimit-Remaining-Requests: 9999
X-Ratelimit-Remaining-Tokens: 999744
X-Ratelimit-Reset-Requests: 6ms
X-Ratelimit-Reset-Tokens: 15ms
X-Request-Id: req_f2650eb5eee54909afd6b2d0fe33a25d
{
"id": "chatcmpl-C5tYT3pvaJbtNYkzj8AuekFBz6Eye",
"object": "chat.completion",
"created": 1755521229,
"model": "gpt-4-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Thought: This is a simple arithmetic problem. I can use the calculator tool to solve it.\nAction: calculator\nAction Input: 5 + 3",
"refusal": null,
"annotations": []
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 229,
"completion_tokens": 35,
"total_tokens": 264,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": null
}
1523 1622
POST https://api.openai.com/v1/chat/completions HTTP/1.1
Host: api.openai.com
User-Agent: langchaingo-httprr
Content-Length: 1320
Authorization: Bearer test-api-key
Content-Type: application/json
{"model":"gpt-4","messages":[{"role":"user","content":"Answer the following questions as best you can. You have access to the following tools:\n\n- GoogleSearch: \n\t\"A wrapper around Google Search. \"\n\t\"Useful for when you need to answer questions about current events. \"\n\t\"Always one of the first options when you need to find information on internet\"\n\t\"Input should be a search query.\"\n- calculator: Useful for getting the result of a math expression. \n\tThe input to this tool should be a valid mathematical expression that could be executed by a starlark evaluator.\n\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [ GoogleSearch, calculator ]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: What is 5 plus 3? Please calculate this.\n\nThought: This is a simple arithmetic problem. I can use the calculator tool to solve it.\nAction: calculator\nAction Input: 5 + 3\nObservation: 8\n"}],"temperature":0,"stop":["\nObservation:","\n\tObservation:"]}HTTP/2.0 200 OK
Content-Length: 854
Access-Control-Expose-Headers: X-Request-ID
Alt-Svc: h3=":443"; ma=86400
Cf-Cache-Status: DYNAMIC
Content-Type: application/json
Date: Mon, 18 Aug 2025 12:47:13 GMT
Openai-Organization: lcgo-tst
Openai-Processing-Ms: 877
Openai-Project: proj_qm9GQ7k7ESiwosypKZaDuaoq
Openai-Version: 2020-10-01
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 976
X-Ratelimit-Limit-Requests: 10000
X-Ratelimit-Limit-Tokens: 1000000
X-Ratelimit-Remaining-Requests: 9999
X-Ratelimit-Remaining-Tokens: 999708
X-Ratelimit-Reset-Requests: 6ms
X-Ratelimit-Reset-Tokens: 17ms
X-Request-Id: req_b87a3934c78c45a293877082fa2a6abe
{
"id": "chatcmpl-C5tYXrnm33bGrlwQU7DjJtce5OgO7",
"object": "chat.completion",
"created": 1755521233,
"model": "gpt-4-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Thought: I now know the final answer\nFinal Answer: The answer is 8.",
"refusal": null,
"annotations": []
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 267,
"completion_tokens": 18,
"total_tokens": 285,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": null
}
================================================
FILE: agents/testdata/TestExecutorWithOpenAIFunctionAgent.httprr
================================================
httprr trace v1
1220 1886
POST https://api.openai.com/v1/chat/completions HTTP/1.1
Host: api.openai.com
User-Agent: langchaingo-httprr
Content-Length: 1017
Authorization: Bearer test-api-key
Content-Type: application/json
{"model":"gpt-4","messages":[{"role":"system","content":"you are a helpful assistant"},{"role":"user","content":"please be strict"},{"role":"user","content":"when was the Go programming language tagged version 1.0?"}],"temperature":0,"tools":[{"type":"function","function":{"name":"GoogleSearch","description":"\n\t\"A wrapper around Google Search. \"\n\t\"Useful for when you need to answer questions about current events. \"\n\t\"Always one of the first options when you need to find information on internet\"\n\t\"Input should be a search query.\"","parameters":{"properties":{"__arg1":{"title":"__arg1","type":"string"}},"required":["__arg1"],"type":"object"}}},{"type":"function","function":{"name":"calculator","description":"Useful for getting the result of a math expression. \n\tThe input to this tool should be a valid mathematical expression that could be executed by a starlark evaluator.","parameters":{"properties":{"__arg1":{"title":"__arg1","type":"string"}},"required":["__arg1"],"type":"object"}}}]}HTTP/2.0 200 OK
Content-Length: 1116
Access-Control-Expose-Headers: X-Request-ID
Alt-Svc: h3=":443"; ma=86400
Cf-Cache-Status: DYNAMIC
Content-Type: application/json
Date: Mon, 18 Aug 2025 12:47:10 GMT
Openai-Organization: lcgo-tst
Openai-Processing-Ms: 1376
Openai-Project: proj_qm9GQ7k7ESiwosypKZaDuaoq
Openai-Version: 2020-10-01
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 1399
X-Ratelimit-Limit-Requests: 10000
X-Ratelimit-Limit-Tokens: 1000000
X-Ratelimit-Remaining-Requests: 9999
X-Ratelimit-Remaining-Tokens: 999971
X-Ratelimit-Reset-Requests: 6ms
X-Ratelimit-Reset-Tokens: 1ms
X-Request-Id: req_374e327388154f3fab4a7ce1251d9024
{
"id": "chatcmpl-C5tYTRMe46wL4MSOA3JiAkb2fJ9ie",
"object": "chat.completion",
"created": 1755521229,
"model": "gpt-4-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_xBZmyTROTl3UDnkHo7ViHPJ6",
"type": "function",
"function": {
"name": "GoogleSearch",
"arguments": "{\n \"__arg1\": \"Go programming language version 1.0 release date\"\n}"
}
}
],
"refusal": null,
"annotations": []
},
"logprobs": null,
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 167,
"completion_tokens": 25,
"total_tokens": 192,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": null
}
202 33610
GET https://serpapi.com/search?api_key=test-api-key&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date HTTP/1.1
Host: serpapi.com
User-Agent: langchaingo-httprr
HTTP/2.0 200 OK
Content-Length: 32942
Alt-Svc: h3=":443"; ma=86400
Cache-Control: max-age=3600, public
Cf-Cache-Status: MISS
Content-Type: application/json; charset=utf-8
Date: Mon, 18 Aug 2025 12:47:14 GMT
Etag: W/"d027446f84bc1f575c1ec556848f1cdf"
Referrer-Policy: strict-origin-when-cross-origin
Serpapi-Search-Id: 68a320cf132583fb7f13e898
Server: cloudflare
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Request-Id: 198c13bc-0704-4695-becf-197d980406e6
X-Robots-Tag: noindex, nofollow
X-Runtime: 2.677962
X-Xss-Protection: 1; mode=block
{
"search_metadata": {
"id": "68a320cf132583fb7f13e898",
"status": "Success",
"json_endpoint": "https://serpapi.com/searches/cb64e13ea8cb4a29/68a320cf132583fb7f13e898.json",
"pixel_position_endpoint": "https://serpapi.com/searches/cb64e13ea8cb4a29/68a320cf132583fb7f13e898.json_with_pixel_position",
"created_at": "2025-08-18 12:47:11 UTC",
"processed_at": "2025-08-18 12:47:11 UTC",
"google_url": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&oq=Go+programming+language+version+1.0+release+date&hl=en&gl=us&sourceid=chrome&ie=UTF-8",
"raw_html_file": "https://serpapi.com/searches/cb64e13ea8cb4a29/68a320cf132583fb7f13e898.html",
"total_time_taken": 2.62
},
"search_parameters": {
"engine": "google",
"q": "Go programming language version 1.0 release date",
"google_domain": "google.com",
"hl": "en",
"gl": "us",
"device": "desktop"
},
"search_information": {
"query_displayed": "Go programming language version 1.0 release date",
"total_results": 13900000,
"time_taken_displayed": 0.27,
"organic_results_state": "Results for exact spelling"
},
"related_questions": [
{
"question": "When did Golang 1.0 come out?",
"type": "featured_snippet",
"snippet": "Go was publicly announced in November 2009, and version 1.0 was released in March 2012.",
"title": "Go (programming language) - Wikipedia",
"link": "https://en.wikipedia.org/wiki/Go_(programming_language)#:~:text=Go%20was%20publicly%20announced%20in,was%20released%20in%20March%202012.",
"displayed_link": "https://en.wikipedia.org › wiki › Go_(programming_la...",
"next_page_token": "eyJvbnMiOiIxMDA0MSIsImZjIjoiRXFFQkNtSkJUR3QwWDNaRlVGQXlWUzFXVUhsMlJuaHFlamRCTVdaR1lWOVFNRzlwYzAxVmJHeEdWbGt3WmtkU1NEZHRPVTlPYzFKVlFsYzRXVUpxWWtaZldteGhiVmRZYUdWSFV6ZHVWa05oY0hSR1kzRnVVbk0yWnpKbVpYQkJaRlpRTVMxVlp4SVhNRk5EYW1GT1pVSktOMUJhTlU5VlVIaEpWelp4VVRRYUlrRkdUVUZIUjNGVWNGazFUWFJFUVhSakxWWkNSR2h4Y25sMVFqUktaM1E0VG5jIiwiZmN2IjoiMyIsImVpIjoiMFNDamFOZUJKN1BaNU9VUHhJVzZxUTQiLCJxYyI6IkNqQm5ieUJ3Y205bmNtRnRiV2x1WnlCc1lXNW5kV0ZuWlNCMlpYSnphVzl1SURFdU1DQnlaV3hsWVhObElHUmhkR1VRQUgwbEtoOF8iLCJxdWVzdGlvbiI6IldoZW4gZGlkIEdvbGFuZyAxLjAgY29tZSBvdXQ/IiwibGsiOiJHaGRuYjJ4aGJtY2djbVZzWldGelpTQmtZWFJsSURFdU1BIiwiYnMiOiJjMzJQc1FyQ01CQ0djYzNVelZnUVRqY1ZwQVlMTHRKUmRCQzNMaTdCWHBOQVRhQkpyY19sTV9rRTdvSUpSY1NsNDNIZmRfOV9aRXZHdVVRTmhTcGdaeXF1QmF5V0NWek1GY0UwTHFPdk5SdkZROUd0YXF5UVc0U0NPd3djT1pESjNuN0YxdFJPZ2lkcXJmeW9OTENFcFJsOW50ZzBCbVZCOUhIa1RPYTU1QzZBVGlKVVBzTTZ1R0Z0bGRGZ1NoOER3Vy00d0l3LUlyYUlaMjJ2SUg0QzJSRHFteDdSbFpXNlEyTkRjdGM3by04MF9PalA2TDkxVnpjYWZBQSIsImlkIjoiZmNfMFNDamFOZUJKN1BaNU9VUHhJVzZxUTRfMSJ9",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google_related_questions&google_domain=google.com&next_page_token=eyJvbnMiOiIxMDA0MSIsImZjIjoiRXFFQkNtSkJUR3QwWDNaRlVGQXlWUzFXVUhsMlJuaHFlamRCTVdaR1lWOVFNRzlwYzAxVmJHeEdWbGt3WmtkU1NEZHRPVTlPYzFKVlFsYzRXVUpxWWtaZldteGhiVmRZYUdWSFV6ZHVWa05oY0hSR1kzRnVVbk0yWnpKbVpYQkJaRlpRTVMxVlp4SVhNRk5EYW1GT1pVSktOMUJhTlU5VlVIaEpWelp4VVRRYUlrRkdUVUZIUjNGVWNGazFUWFJFUVhSakxWWkNSR2h4Y25sMVFqUktaM1E0VG5jIiwiZmN2IjoiMyIsImVpIjoiMFNDamFOZUJKN1BaNU9VUHhJVzZxUTQiLCJxYyI6IkNqQm5ieUJ3Y205bmNtRnRiV2x1WnlCc1lXNW5kV0ZuWlNCMlpYSnphVzl1SURFdU1DQnlaV3hsWVhObElHUmhkR1VRQUgwbEtoOF8iLCJxdWVzdGlvbiI6IldoZW4gZGlkIEdvbGFuZyAxLjAgY29tZSBvdXQ%2FIiwibGsiOiJHaGRuYjJ4aGJtY2djbVZzWldGelpTQmtZWFJsSURFdU1BIiwiYnMiOiJjMzJQc1FyQ01CQ0djYzNVelZnUVRqY1ZwQVlMTHRKUmRCQzNMaTdCWHBOQVRhQkpyY19sTV9rRTdvSUpSY1NsNDNIZmRfOV9aRXZHdVVRTmhTcGdaeXF1QmF5V0NWek1GY0UwTHFPdk5SdkZROUd0YXF5UVc0U0NPd3djT1pESjNuN0YxdFJPZ2lkcXJmeW9OTENFcFJsOW50ZzBCbVZCOUhIa1RPYTU1QzZBVGlKVVBzTTZ1R0Z0bGRGZ1NoOER3Vy00d0l3LUlyYUlaMjJ2SUg0QzJSRHFteDdSbFpXNlEyTkRjdGM3by04MF9PalA2TDkxVnpjYWZBQSIsImlkIjoiZmNfMFNDamFOZUJKN1BaNU9VUHhJVzZxUTRfMSJ9"
},
{
"question": "Is Golang worth learning in 2025?",
"type": "featured_snippet",
"snippet": "In 2025, Go's still the king of: Fast development cycles — Go's syntax is so simple that I can ship features crazy quick. Easy onboarding — Last month we hired a junior dev who'd never used Go before.",
"title": "Beyond Language Wars: When to Choose Go vs Rust for Modern ...",
"date": "Mar 14, 2025",
"link": "https://medium.com/@utsavmadaan823/beyond-language-wars-when-to-choose-go-vs-rust-for-modern-development-in-2025-062301dcee9b#:~:text=In%202025%2C%20Go's%20still%20the,d%20never%20used%20Go%20before.",
"displayed_link": "https://medium.com › beyond-language-wars-when-to-c...",
"source_logo": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/3e0339b7a87af1536697b1f12ade968081ee52a6a18b79a5a464fbb6ceccdffe.png",
"next_page_token": "eyJvbnMiOiIxMDA0MSIsImZjIjoiRXFFQkNtSkJUR3QwWDNaRlVGQXlWUzFXVUhsMlJuaHFlamRCTVdaR1lWOVFNRzlwYzAxVmJHeEdWbGt3WmtkU1NEZHRPVTlPYzFKVlFsYzRXVUpxWWtaZldteGhiVmRZYUdWSFV6ZHVWa05oY0hSR1kzRnVVbk0yWnpKbVpYQkJaRlpRTVMxVlp4SVhNRk5EYW1GT1pVSktOMUJhTlU5VlVIaEpWelp4VVRRYUlrRkdUVUZIUjNGVWNGazFUWFJFUVhSakxWWkNSR2h4Y25sMVFqUktaM1E0VG5jIiwiZmN2IjoiMyIsImVpIjoiMFNDamFOZUJKN1BaNU9VUHhJVzZxUTQiLCJxYyI6IkNqQm5ieUJ3Y205bmNtRnRiV2x1WnlCc1lXNW5kV0ZuWlNCMlpYSnphVzl1SURFdU1DQnlaV3hsWVhObElHUmhkR1VRQUgwbEtoOF8iLCJxdWVzdGlvbiI6IklzIEdvbGFuZyB3b3J0aCBsZWFybmluZyBpbiAyMDI1PyIsImxrIjoiR2lCcGN5Qm5iMnhoYm1jZ2QyOXlkR2dnYkdWaGNtNXBibWNnYVc0Z01qQXlOUSIsImJzIjoiYzMyUHNRckNNQkNHY2MzVXpWZ1FUamNWcEFZTEx0SlJkQkMzTGk3QlhwTkFUYUJKcmNfbE1fa0U3b0lKUmNTbDQzSGZkXzlfWkV2R3VVUU5oU3BnWnlxdUJheVdDVnpNRmNFMExxT3ZOUnZGUTlHdGFxeVFXNFNDT3d3Y09aREozbjdGMXRST2dpZHFyZnlvTkxDRXBSbDludGcwQm1WQjlISGtUT2E1NUM2QVRpSlVQc002dUdGdGxkRmdTaDhEd1ctNHdJdy1JcmFJWjIydklINEMyUkRxbXg3UmxaVzZRMk5EY3RjN28tODBfT2pQNkw5MVZ6Y2FmQUEiLCJpZCI6ImZjXzBTQ2phTmVCSjdQWjVPVVB4SVc2cVE0XzEifQ==",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google_related_questions&google_domain=google.com&next_page_token=eyJvbnMiOiIxMDA0MSIsImZjIjoiRXFFQkNtSkJUR3QwWDNaRlVGQXlWUzFXVUhsMlJuaHFlamRCTVdaR1lWOVFNRzlwYzAxVmJHeEdWbGt3WmtkU1NEZHRPVTlPYzFKVlFsYzRXVUpxWWtaZldteGhiVmRZYUdWSFV6ZHVWa05oY0hSR1kzRnVVbk0yWnpKbVpYQkJaRlpRTVMxVlp4SVhNRk5EYW1GT1pVSktOMUJhTlU5VlVIaEpWelp4VVRRYUlrRkdUVUZIUjNGVWNGazFUWFJFUVhSakxWWkNSR2h4Y25sMVFqUktaM1E0VG5jIiwiZmN2IjoiMyIsImVpIjoiMFNDamFOZUJKN1BaNU9VUHhJVzZxUTQiLCJxYyI6IkNqQm5ieUJ3Y205bmNtRnRiV2x1WnlCc1lXNW5kV0ZuWlNCMlpYSnphVzl1SURFdU1DQnlaV3hsWVhObElHUmhkR1VRQUgwbEtoOF8iLCJxdWVzdGlvbiI6IklzIEdvbGFuZyB3b3J0aCBsZWFybmluZyBpbiAyMDI1PyIsImxrIjoiR2lCcGN5Qm5iMnhoYm1jZ2QyOXlkR2dnYkdWaGNtNXBibWNnYVc0Z01qQXlOUSIsImJzIjoiYzMyUHNRckNNQkNHY2MzVXpWZ1FUamNWcEFZTEx0SlJkQkMzTGk3QlhwTkFUYUJKcmNfbE1fa0U3b0lKUmNTbDQzSGZkXzlfWkV2R3VVUU5oU3BnWnlxdUJheVdDVnpNRmNFMExxT3ZOUnZGUTlHdGFxeVFXNFNDT3d3Y09aREozbjdGMXRST2dpZHFyZnlvTkxDRXBSbDludGcwQm1WQjlISGtUT2E1NUM2QVRpSlVQc002dUdGdGxkRmdTaDhEd1ctNHdJdy1JcmFJWjIydklINEMyUkRxbXg3UmxaVzZRMk5EY3RjN28tODBfT2pQNkw5MVZ6Y2FmQUEiLCJpZCI6ImZjXzBTQ2phTmVCSjdQWjVPVVB4SVc2cVE0XzEifQ%3D%3D"
},
{
"question": "What is the latest version of Go language?",
"type": "featured_snippet",
"snippet": "The latest Go release, version 1.25, arrives in August 2025, six months after Go 1.24. Most of its changes are in the implementation of the toolchain, runtime, and libraries. As always, the release maintains the Go 1 promise of compatibility. We expect almost all Go programs to continue to compile and run as before.",
"title": "Go 1.25 Release Notes - The Go Programming Language",
"link": "https://tip.golang.org/doc/go1.25#:~:text=The%20latest%20Go%20release%2C%20version,compile%20and%20run%20as%20before.",
"displayed_link": "https://tip.golang.org › doc",
"source_logo": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/3e0339b7a87af1536697b1f12ade9680071d3372b353e543b1985a98526e131f.png",
"next_page_token": "eyJvbnMiOiIxMDA0MSIsImZjIjoiRXFFQkNtSkJUR3QwWDNaRlVGQXlWUzFXVUhsMlJuaHFlamRCTVdaR1lWOVFNRzlwYzAxVmJHeEdWbGt3WmtkU1NEZHRPVTlPYzFKVlFsYzRXVUpxWWtaZldteGhiVmRZYUdWSFV6ZHVWa05oY0hSR1kzRnVVbk0yWnpKbVpYQkJaRlpRTVMxVlp4SVhNRk5EYW1GT1pVSktOMUJhTlU5VlVIaEpWelp4VVRRYUlrRkdUVUZIUjNGVWNGazFUWFJFUVhSakxWWkNSR2h4Y25sMVFqUktaM1E0VG5jIiwiZmN2IjoiMyIsImVpIjoiMFNDamFOZUJKN1BaNU9VUHhJVzZxUTQiLCJxYyI6IkNqQm5ieUJ3Y205bmNtRnRiV2x1WnlCc1lXNW5kV0ZuWlNCMlpYSnphVzl1SURFdU1DQnlaV3hsWVhObElHUmhkR1VRQUgwbEtoOF8iLCJxdWVzdGlvbiI6IldoYXQgaXMgdGhlIGxhdGVzdCB2ZXJzaW9uIG9mIEdvIGxhbmd1YWdlPyIsImxrIjoiR2lsM2FHRjBJR2x6SUhSb1pTQnNZWFJsYzNRZ2RtVnljMmx2YmlCdlppQm5ieUJzWVc1bmRXRm5aUSIsImJzIjoiYzMyUHNRckNNQkNHY2MzVXpWZ1FUamNWcEFZTEx0SlJkQkMzTGk3QlhwTkFUYUJKcmNfbE1fa0U3b0lKUmNTbDQzSGZkXzlfWkV2R3VVUU5oU3BnWnlxdUJheVdDVnpNRmNFMExxT3ZOUnZGUTlHdGFxeVFXNFNDT3d3Y09aREozbjdGMXRST2dpZHFyZnlvTkxDRXBSbDludGcwQm1WQjlISGtUT2E1NUM2QVRpSlVQc002dUdGdGxkRmdTaDhEd1ctNHdJdy1JcmFJWjIydklINEMyUkRxbXg3UmxaVzZRMk5EY3RjN28tODBfT2pQNkw5MVZ6Y2FmQUEiLCJpZCI6ImZjXzBTQ2phTmVCSjdQWjVPVVB4SVc2cVE0XzEifQ==",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google_related_questions&google_domain=google.com&next_page_token=eyJvbnMiOiIxMDA0MSIsImZjIjoiRXFFQkNtSkJUR3QwWDNaRlVGQXlWUzFXVUhsMlJuaHFlamRCTVdaR1lWOVFNRzlwYzAxVmJHeEdWbGt3WmtkU1NEZHRPVTlPYzFKVlFsYzRXVUpxWWtaZldteGhiVmRZYUdWSFV6ZHVWa05oY0hSR1kzRnVVbk0yWnpKbVpYQkJaRlpRTVMxVlp4SVhNRk5EYW1GT1pVSktOMUJhTlU5VlVIaEpWelp4VVRRYUlrRkdUVUZIUjNGVWNGazFUWFJFUVhSakxWWkNSR2h4Y25sMVFqUktaM1E0VG5jIiwiZmN2IjoiMyIsImVpIjoiMFNDamFOZUJKN1BaNU9VUHhJVzZxUTQiLCJxYyI6IkNqQm5ieUJ3Y205bmNtRnRiV2x1WnlCc1lXNW5kV0ZuWlNCMlpYSnphVzl1SURFdU1DQnlaV3hsWVhObElHUmhkR1VRQUgwbEtoOF8iLCJxdWVzdGlvbiI6IldoYXQgaXMgdGhlIGxhdGVzdCB2ZXJzaW9uIG9mIEdvIGxhbmd1YWdlPyIsImxrIjoiR2lsM2FHRjBJR2x6SUhSb1pTQnNZWFJsYzNRZ2RtVnljMmx2YmlCdlppQm5ieUJzWVc1bmRXRm5aUSIsImJzIjoiYzMyUHNRckNNQkNHY2MzVXpWZ1FUamNWcEFZTEx0SlJkQkMzTGk3QlhwTkFUYUJKcmNfbE1fa0U3b0lKUmNTbDQzSGZkXzlfWkV2R3VVUU5oU3BnWnlxdUJheVdDVnpNRmNFMExxT3ZOUnZGUTlHdGFxeVFXNFNDT3d3Y09aREozbjdGMXRST2dpZHFyZnlvTkxDRXBSbDludGcwQm1WQjlISGtUT2E1NUM2QVRpSlVQc002dUdGdGxkRmdTaDhEd1ctNHdJdy1JcmFJWjIydklINEMyUkRxbXg3UmxaVzZRMk5EY3RjN28tODBfT2pQNkw5MVZ6Y2FmQUEiLCJpZCI6ImZjXzBTQ2phTmVCSjdQWjVPVVB4SVc2cVE0XzEifQ%3D%3D"
},
{
"question": "Is Netflix using Golang?",
"type": "featured_snippet",
"snippet": "Distributed Tracing Systems: Go helps monitor and debug microservices at scale. Cloud Orchestration: Netflix uses Go to manage thousands of microservices.",
"title": "How Companies Use Golang: 7 Real Examples | Medium",
"date": "Mar 12, 2025",
"link": "https://renaldid.medium.com/how-companies-use-golang-7-real-world-examples-you-need-to-know-f9a93d86ca25#:~:text=Distributed%20Tracing%20Systems%3A%20Go%20helps,to%20manage%20thousands%20of%20microservices.",
"displayed_link": "https://renaldid.medium.com › ...",
"source_logo": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/3e0339b7a87af1536697b1f12ade9680af73f8e05bec4b50cc85782ce3349086.png",
"next_page_token": "eyJvbnMiOiIxMDA0MSIsImZjIjoiRXFFQkNtSkJUR3QwWDNaRlVGQXlWUzFXVUhsMlJuaHFlamRCTVdaR1lWOVFNRzlwYzAxVmJHeEdWbGt3WmtkU1NEZHRPVTlPYzFKVlFsYzRXVUpxWWtaZldteGhiVmRZYUdWSFV6ZHVWa05oY0hSR1kzRnVVbk0yWnpKbVpYQkJaRlpRTVMxVlp4SVhNRk5EYW1GT1pVSktOMUJhTlU5VlVIaEpWelp4VVRRYUlrRkdUVUZIUjNGVWNGazFUWFJFUVhSakxWWkNSR2h4Y25sMVFqUktaM1E0VG5jIiwiZmN2IjoiMyIsImVpIjoiMFNDamFOZUJKN1BaNU9VUHhJVzZxUTQiLCJxYyI6IkNqQm5ieUJ3Y205bmNtRnRiV2x1WnlCc1lXNW5kV0ZuWlNCMlpYSnphVzl1SURFdU1DQnlaV3hsWVhObElHUmhkR1VRQUgwbEtoOF8iLCJxdWVzdGlvbiI6IklzIE5ldGZsaXggdXNpbmcgR29sYW5nPyIsImxrIjoiR2hkcGN5QnVaWFJtYkdsNElIVnphVzVuSUdkdmJHRnVadyIsImJzIjoiYzMyUHNRckNNQkNHY2MzVXpWZ1FUamNWcEFZTEx0SlJkQkMzTGk3QlhwTkFUYUJKcmNfbE1fa0U3b0lKUmNTbDQzSGZkXzlfWkV2R3VVUU5oU3BnWnlxdUJheVdDVnpNRmNFMExxT3ZOUnZGUTlHdGFxeVFXNFNDT3d3Y09aREozbjdGMXRST2dpZHFyZnlvTkxDRXBSbDludGcwQm1WQjlISGtUT2E1NUM2QVRpSlVQc002dUdGdGxkRmdTaDhEd1ctNHdJdy1JcmFJWjIydklINEMyUkRxbXg3UmxaVzZRMk5EY3RjN28tODBfT2pQNkw5MVZ6Y2FmQUEiLCJpZCI6ImZjXzBTQ2phTmVCSjdQWjVPVVB4SVc2cVE0XzEifQ==",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google_related_questions&google_domain=google.com&next_page_token=eyJvbnMiOiIxMDA0MSIsImZjIjoiRXFFQkNtSkJUR3QwWDNaRlVGQXlWUzFXVUhsMlJuaHFlamRCTVdaR1lWOVFNRzlwYzAxVmJHeEdWbGt3WmtkU1NEZHRPVTlPYzFKVlFsYzRXVUpxWWtaZldteGhiVmRZYUdWSFV6ZHVWa05oY0hSR1kzRnVVbk0yWnpKbVpYQkJaRlpRTVMxVlp4SVhNRk5EYW1GT1pVSktOMUJhTlU5VlVIaEpWelp4VVRRYUlrRkdUVUZIUjNGVWNGazFUWFJFUVhSakxWWkNSR2h4Y25sMVFqUktaM1E0VG5jIiwiZmN2IjoiMyIsImVpIjoiMFNDamFOZUJKN1BaNU9VUHhJVzZxUTQiLCJxYyI6IkNqQm5ieUJ3Y205bmNtRnRiV2x1WnlCc1lXNW5kV0ZuWlNCMlpYSnphVzl1SURFdU1DQnlaV3hsWVhObElHUmhkR1VRQUgwbEtoOF8iLCJxdWVzdGlvbiI6IklzIE5ldGZsaXggdXNpbmcgR29sYW5nPyIsImxrIjoiR2hkcGN5QnVaWFJtYkdsNElIVnphVzVuSUdkdmJHRnVadyIsImJzIjoiYzMyUHNRckNNQkNHY2MzVXpWZ1FUamNWcEFZTEx0SlJkQkMzTGk3QlhwTkFUYUJKcmNfbE1fa0U3b0lKUmNTbDQzSGZkXzlfWkV2R3VVUU5oU3BnWnlxdUJheVdDVnpNRmNFMExxT3ZOUnZGUTlHdGFxeVFXNFNDT3d3Y09aREozbjdGMXRST2dpZHFyZnlvTkxDRXBSbDludGcwQm1WQjlISGtUT2E1NUM2QVRpSlVQc002dUdGdGxkRmdTaDhEd1ctNHdJdy1JcmFJWjIydklINEMyUkRxbXg3UmxaVzZRMk5EY3RjN28tODBfT2pQNkw5MVZ6Y2FmQUEiLCJpZCI6ImZjXzBTQ2phTmVCSjdQWjVPVVB4SVc2cVE0XzEifQ%3D%3D"
}
],
"ai_overview": {
"page_token": "C2ynj3icxZTLkrJGFMe3eZGw8VPwjlNFpZqbIt5ax_GysRCwuQgoeMNd3iXvk32eJt2tzIczY2pSWaQX0LT_Puf0v3-e3__YuqH_1y9_OofDLnlh2fP5XEJRhLZ2yYwC1kjS0GQ30TaJTec3tBWOCeNsBTtk0pNQZcxE4BjbFbiJ5BkDW-w2R8v6cDq6aLPGHtYYul1YrY3E9nD0i5ewKxY__F-rMv4oJSU7LC36vnJRl_Wyk5QqXKVeGrJGgAXgPw_0xRoEY_pUJPK8DTwFChCfhSFSADQsy0mknKCvEJWmEpUogcchZVUoPgK10apYy4fOhfPzu3pkl6vjErWu9qmin3XAewyUz_RVjXexBuTbYZ4MKWcLCYiFG3TP0aEF061DvRvl0nRQ35SH-uQrw4GoAxSA0U48w2dpd9CvJAMIEGshfPMcu47xq8zGCeFAem1xUUcq9s6zEQrqy3kDVsf913r6WnXNmdwEPyhhZvKOWJJHrCW1TkBPFvEclXolsfzOl6QQJyH1rn0rxMGHUcFzFG4uZgbR4-Y51TLzCGN7HfRF8qnJSDpDsMtUIyC2h3Cf2XPbp4EcX8QomSzRDN5CFQlfCgmG-YLAJd8ES0lBmBtyDk3EK_QU5xqNg7KKEOjYYiqdye2J92rlBb04ypf2jqHyk5js7wCpNXPk4bkbgZ7I1eBdpQGoiNRAqoX0pruUEoDPDR28c8DJiFoiadQTDVGlmgGr0NyzmxEywI7hSe8DX1TT_6croUN9_hP6AijFgnHzWO2ru4UCr2kP8kF15CvL5drJgIqC9b9oWub_hxyxdoz71F6HOeSmz5FTJIKc9oiclEPOvCGnwltLe0ROypBTfL9NW1oOOSWHnJ9Hbv3Q0j4iJ34PuckH5MbvyHWfIedKj8jh3Bs0owWIHYqc9gm5b7Y09VstjZJn316P_e3ooU99LpxNR-Ph2nT8qze_Fpuny7kDa8234hJjuQkOL7s4Qj9WrvUiVrqH1GL2QjsqkMXYCAI3RIWtEaKjgezCyY4TNwoL5RJXiO2tjZkuWMbBZoJtHAmcUY8nIBgMq4OLvzB0o9tdLg9pCLVpfWDLQ3W90b20BdR5Ma3U3vrIKUrNnnatT6B8mL2lsSK9zfX2ZMVbDa6tmz1-F-pxONXQdnwNiseK0QY9_dzQ0_7RMfmi2BQt3gumYMlbarXT2m52l_loXH7dIHW_sN9miNaVCNf5fDk3xIUXK0xgWIktlJkgNgV8jzUfYE8hk5jGyk5OAm_xPG-WK9am0dw0uCYToEO6E_i_ATv6jxE",
"serpapi_link": "https://serpapi.com/search.json?engine=google_ai_overview&page_token=C2ynj3icxZTLkrJGFMe3eZGw8VPwjlNFpZqbIt5ax_GysRCwuQgoeMNd3iXvk32eJt2tzIczY2pSWaQX0LT_Puf0v3-e3__YuqH_1y9_OofDLnlh2fP5XEJRhLZ2yYwC1kjS0GQ30TaJTec3tBWOCeNsBTtk0pNQZcxE4BjbFbiJ5BkDW-w2R8v6cDq6aLPGHtYYul1YrY3E9nD0i5ewKxY__F-rMv4oJSU7LC36vnJRl_Wyk5QqXKVeGrJGgAXgPw_0xRoEY_pUJPK8DTwFChCfhSFSADQsy0mknKCvEJWmEpUogcchZVUoPgK10apYy4fOhfPzu3pkl6vjErWu9qmin3XAewyUz_RVjXexBuTbYZ4MKWcLCYiFG3TP0aEF061DvRvl0nRQ35SH-uQrw4GoAxSA0U48w2dpd9CvJAMIEGshfPMcu47xq8zGCeFAem1xUUcq9s6zEQrqy3kDVsf913r6WnXNmdwEPyhhZvKOWJJHrCW1TkBPFvEclXolsfzOl6QQJyH1rn0rxMGHUcFzFG4uZgbR4-Y51TLzCGN7HfRF8qnJSDpDsMtUIyC2h3Cf2XPbp4EcX8QomSzRDN5CFQlfCgmG-YLAJd8ES0lBmBtyDk3EK_QU5xqNg7KKEOjYYiqdye2J92rlBb04ypf2jqHyk5js7wCpNXPk4bkbgZ7I1eBdpQGoiNRAqoX0pruUEoDPDR28c8DJiFoiadQTDVGlmgGr0NyzmxEywI7hSe8DX1TT_6croUN9_hP6AijFgnHzWO2ru4UCr2kP8kF15CvL5drJgIqC9b9oWub_hxyxdoz71F6HOeSmz5FTJIKc9oiclEPOvCGnwltLe0ROypBTfL9NW1oOOSWHnJ9Hbv3Q0j4iJ34PuckH5MbvyHWfIedKj8jh3Bs0owWIHYqc9gm5b7Y09VstjZJn316P_e3ooU99LpxNR-Ph2nT8qze_Fpuny7kDa8234hJjuQkOL7s4Qj9WrvUiVrqH1GL2QjsqkMXYCAI3RIWtEaKjgezCyY4TNwoL5RJXiO2tjZkuWMbBZoJtHAmcUY8nIBgMq4OLvzB0o9tdLg9pCLVpfWDLQ3W90b20BdR5Ma3U3vrIKUrNnnatT6B8mL2lsSK9zfX2ZMVbDa6tmz1-F-pxONXQdnwNiseK0QY9_dzQ0_7RMfmi2BQt3gumYMlbarXT2m52l_loXH7dIHW_sN9miNaVCNf5fDk3xIUXK0xgWIktlJkgNgV8jzUfYE8hk5jGyk5OAm_xPG-WK9am0dw0uCYToEO6E_i_ATv6jxE"
},
"organic_results": [
{
"position": 1,
"title": "Go (programming language)",
"link": "https://en.wikipedia.org/wiki/Go_(programming_language)",
"redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://en.wikipedia.org/wiki/Go_(programming_language)&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQFnoECBgQAQ",
"displayed_link": "https://en.wikipedia.org › wiki › Go_(programming_la...",
"favicon": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/339c6efa2d70a92b0636a4a2eb59cc0d92a78e4c3a0ed6171f9dfd469969b861.png",
"snippet": "Its designers were primarily motivated by their shared dislike of C++. Go was publicly announced in November 2009, and version 1.0 was released in March 2012. ...",
"source": "Wikipedia"
},
{
"position": 2,
"title": "Go version 1 is released",
"link": "https://go.dev/blog/go1",
"redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://go.dev/blog/go1&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQFnoECBcQAQ",
"displayed_link": "https://go.dev › blog",
"favicon": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/339c6efa2d70a92b0636a4a2eb59cc0df06f2c6cb6c4c50a48b97766ec1ae332.png",
"date": "Mar 28, 2012",
"snippet": "Go 1 is the first release of Go that is available in supported binary distributions. They are available for Linux, FreeBSD, Mac OS X and, we are thrilled to ...",
"snippet_highlighted_words": [
"Go 1 is the first release of Go"
],
"source": "The Go Programming Language"
},
{
"position": 3,
"title": "Release History",
"link": "https://go.dev/doc/devel/release",
"redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://go.dev/doc/devel/release&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQFnoECC4QAQ",
"displayed_link": "https://go.dev › doc › devel › release",
"favicon": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/339c6efa2d70a92b0636a4a2eb59cc0d1e64c549ee2fe539fc03add102eb91c5.png",
"snippet": "go1.23.0 (released 2024-08-13). Go 1.23.0 is a major release of Go. Read the Go 1.23 Release Notes for more information. Minor revisions. go1.",
"snippet_highlighted_words": [
"Go",
"release",
"Go",
"Go",
"Release"
],
"source": "The Go Programming Language"
},
{
"position": 4,
"title": "The Evolution of the Go Programming Language",
"link": "https://www.bytesizego.com/blog/go-language-history",
"redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.bytesizego.com/blog/go-language-history&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQFnoECC8QAQ",
"displayed_link": "https://www.bytesizego.com › blog › go-language-history",
"date": "Nov 24, 2024",
"snippet": "The Initial Release of Go 1.0 (2012). The first big moment in Go's history came in March 2012, with the release of Go 1.0. This wasn't just ...",
"snippet_highlighted_words": [
"March 2012"
],
"source": "ByteSizeGo"
},
{
"position": 5,
"title": "The Go programming language — everything you should ...",
"link": "https://codilime.com/blog/what-is-go-language/",
"redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://codilime.com/blog/what-is-go-language/&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQFnoECDIQAQ",
"displayed_link": "https://codilime.com › ... › Backend",
"favicon": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/339c6efa2d70a92b0636a4a2eb59cc0d3d2f78f633cbf3af40ba0c6578dbd6fb.png",
"date": "Sep 17, 2021",
"snippet": "After three more years, in March 2012, version 1.0 of the Go language was released.",
"snippet_highlighted_words": [
"March 2012"
],
"source": "CodiLime"
},
{
"position": 6,
"title": "A Journey Through Time: A Brief History of Golang",
"link": "https://plavno.io/blog/history-of-golang",
"redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://plavno.io/blog/history-of-golang&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQFnoECDAQAQ",
"displayed_link": "https://plavno.io › Blog",
"favicon": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/339c6efa2d70a92b0636a4a2eb59cc0d100073620a4edcec6e1b4ff2c8de6592.png",
"date": "Jun 9, 2023",
"snippet": "Go 1.0: A Groundbreaking Release: The release of Go 1.0 in March 2012 marked a crucial milestone in Golang's journey. This version solidified ...",
"snippet_highlighted_words": [
"March 2012"
],
"source": "Plavno"
},
{
"position": 7,
"title": "Go Version 1 Released",
"link": "https://developers.slashdot.org/story/12/03/28/1852230/go-version-1-released",
"redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://developers.slashdot.org/story/12/03/28/1852230/go-version-1-released&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQFnoECDEQAQ",
"displayed_link": "https://developers.slashdot.org › story › go-version-1-re...",
"favicon": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/339c6efa2d70a92b0636a4a2eb59cc0d37caa7038f75864368be1522a9fa185e.jpeg",
"date": "Mar 28, 2012",
"snippet": "New submitter smwny writes Google's system programming language, Go, has just reached the 1.0 milestone. From the announcement: 'Go 1 is the ...",
"snippet_highlighted_words": [
"Google's system programming language, Go"
],
"source": "Slashdot"
},
{
"position": 8,
"title": "Go 1.0.1 is out! : r/golang",
"link": "https://www.reddit.com/r/golang/comments/suaxl/go_101_is_out/",
"redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.reddit.com/r/golang/comments/suaxl/go_101_is_out/&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQFnoECDUQAQ",
"displayed_link": "4 comments · 13 years ago",
"favicon": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/339c6efa2d70a92b0636a4a2eb59cc0db8b9742a3bdc30a36849f18adfa7ede7.png",
"snippet": "Unlike most weeklies, there are no functional changes or additions in this release. It's just fixes, and nearly all of them are trivial. The ...",
"snippet_highlighted_words": [
"release"
],
"source": "Reddit · r/golang"
},
{
"position": 9,
"title": "Go / Golang - The Google Programming Language",
"link": "https://www.ionos.com/digitalguide/server/know-how/golang/",
"redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.ionos.com/digitalguide/server/know-how/golang/&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQFnoECDMQAQ",
"displayed_link": "https://www.ionos.com › ... › Know-how › Golang",
"favicon": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/339c6efa2d70a92b0636a4a2eb59cc0df29a85900ce3f965f1b8c2eb06052bd8.png",
"date": "Mar 21, 2023",
"snippet": "The final release of the first stable version (1.0) took place on March 28, 2012. ... programming languages used to date, but as a possible ...",
"snippet_highlighted_words": [
"release",
"version",
"1.0",
"programming",
"date"
],
"source": "IONOS » Hosting Provider"
},
{
"position": 10,
"title": "Go 1.0.3 is out : r/golang",
"link": "https://www.reddit.com/r/golang/comments/10emh3/go_103_is_out/",
"redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.reddit.com/r/golang/comments/10emh3/go_103_is_out/&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQFnoECDcQAQ",
"displayed_link": "10+ comments · 12 years ago",
"favicon": "https://serpapi.com/searches/68a320cf132583fb7f13e898/images/339c6efa2d70a92b0636a4a2eb59cc0d3ed8338ea48b025896f03dac033d5195.png",
"snippet": "I compiled the latest release from source just yesterday (and the cross compiler for windows/amd64) and a few minutes ago I updated to 1.0.3.",
"snippet_highlighted_words": [
"release",
"1.0"
],
"source": "Reddit · r/golang"
}
],
"related_searches": [
{
"block_position": 1,
"query": "Go programming language version 1.0 release date github",
"link": "https://www.google.com/search?sca_esv=8d888c12df67f607&gl=us&hl=en&q=Go+programming+language+version+1.0+release+date+github&sa=X&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ1QJ6BAhGEAE",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date+github"
},
{
"block_position": 1,
"query": "Golang release date",
"link": "https://www.google.com/search?sca_esv=8d888c12df67f607&gl=us&hl=en&q=Golang+release+date&sa=X&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ1QJ6BAg_EAE",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Golang+release+date"
},
{
"block_position": 1,
"query": "Go 1.25 release date",
"link": "https://www.google.com/search?sca_esv=8d888c12df67f607&gl=us&hl=en&q=Go+1.25+release+date&sa=X&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ1QJ6BAg4EAE",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+1.25+release+date"
},
{
"block_position": 1,
"query": "Golang 1.23 release date",
"link": "https://www.google.com/search?sca_esv=8d888c12df67f607&gl=us&hl=en&q=Golang+1.23+release+date&sa=X&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ1QJ6BAg2EAE",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Golang+1.23+release+date"
},
{
"block_position": 1,
"query": "go (programming language) designed by",
"link": "https://www.google.com/search?sca_esv=8d888c12df67f607&gl=us&hl=en&q=go+(programming+language)+designed+by&sa=X&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ1QJ6BAg0EAE",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=go+%28programming+language%29+designed+by"
},
{
"block_position": 1,
"query": "Golang version history",
"link": "https://www.google.com/search?sca_esv=8d888c12df67f607&gl=us&hl=en&q=Golang+version+history&sa=X&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ1QJ6BAgtEAE",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Golang+version+history"
},
{
"block_position": 1,
"query": "Go 1.22 release date",
"link": "https://www.google.com/search?sca_esv=8d888c12df67f607&gl=us&hl=en&q=Go+1.22+release+date&sa=X&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ1QJ6BAgsEAE",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+1.22+release+date"
},
{
"block_position": 1,
"query": "Golang latest version",
"link": "https://www.google.com/search?sca_esv=8d888c12df67f607&gl=us&hl=en&q=Golang+latest+version&sa=X&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ1QJ6BAgrEAE",
"serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Golang+latest+version"
}
],
"pagination": {
"current": 1,
"next": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&sca_esv=8d888c12df67f607&gl=us&hl=en&ei=0SCjaNeBJ7PZ5OUPxIW6qQ4&start=10&sa=N&sstk=Ac65TH4GMu9hunGkMTuKViJxVZFX5vVYXMpnHXx1et4fgOJFfBaKLzAp3BigXJp4j8940bYB0JFHI--7siqQ4WEa8r759RVv_MPizw&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ8NMDegQIChAW",
"other_pages": {
"2": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&sca_esv=8d888c12df67f607&gl=us&hl=en&ei=0SCjaNeBJ7PZ5OUPxIW6qQ4&start=10&sa=N&sstk=Ac65TH4GMu9hunGkMTuKViJxVZFX5vVYXMpnHXx1et4fgOJFfBaKLzAp3BigXJp4j8940bYB0JFHI--7siqQ4WEa8r759RVv_MPizw&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ8tMDegQIChAE",
"3": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&sca_esv=8d888c12df67f607&gl=us&hl=en&ei=0SCjaNeBJ7PZ5OUPxIW6qQ4&start=20&sa=N&sstk=Ac65TH4GMu9hunGkMTuKViJxVZFX5vVYXMpnHXx1et4fgOJFfBaKLzAp3BigXJp4j8940bYB0JFHI--7siqQ4WEa8r759RVv_MPizw&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ8tMDegQIChAG",
"4": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&sca_esv=8d888c12df67f607&gl=us&hl=en&ei=0SCjaNeBJ7PZ5OUPxIW6qQ4&start=30&sa=N&sstk=Ac65TH4GMu9hunGkMTuKViJxVZFX5vVYXMpnHXx1et4fgOJFfBaKLzAp3BigXJp4j8940bYB0JFHI--7siqQ4WEa8r759RVv_MPizw&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ8tMDegQIChAI",
"5": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&sca_esv=8d888c12df67f607&gl=us&hl=en&ei=0SCjaNeBJ7PZ5OUPxIW6qQ4&start=40&sa=N&sstk=Ac65TH4GMu9hunGkMTuKViJxVZFX5vVYXMpnHXx1et4fgOJFfBaKLzAp3BigXJp4j8940bYB0JFHI--7siqQ4WEa8r759RVv_MPizw&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ8tMDegQIChAK",
"6": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&sca_esv=8d888c12df67f607&gl=us&hl=en&ei=0SCjaNeBJ7PZ5OUPxIW6qQ4&start=50&sa=N&sstk=Ac65TH4GMu9hunGkMTuKViJxVZFX5vVYXMpnHXx1et4fgOJFfBaKLzAp3BigXJp4j8940bYB0JFHI--7siqQ4WEa8r759RVv_MPizw&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ8tMDegQIChAM",
"7": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&sca_esv=8d888c12df67f607&gl=us&hl=en&ei=0SCjaNeBJ7PZ5OUPxIW6qQ4&start=60&sa=N&sstk=Ac65TH4GMu9hunGkMTuKViJxVZFX5vVYXMpnHXx1et4fgOJFfBaKLzAp3BigXJp4j8940bYB0JFHI--7siqQ4WEa8r759RVv_MPizw&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ8tMDegQIChAO",
"8": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&sca_esv=8d888c12df67f607&gl=us&hl=en&ei=0SCjaNeBJ7PZ5OUPxIW6qQ4&start=70&sa=N&sstk=Ac65TH4GMu9hunGkMTuKViJxVZFX5vVYXMpnHXx1et4fgOJFfBaKLzAp3BigXJp4j8940bYB0JFHI--7siqQ4WEa8r759RVv_MPizw&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ8tMDegQIChAQ",
"9": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&sca_esv=8d888c12df67f607&gl=us&hl=en&ei=0SCjaNeBJ7PZ5OUPxIW6qQ4&start=80&sa=N&sstk=Ac65TH4GMu9hunGkMTuKViJxVZFX5vVYXMpnHXx1et4fgOJFfBaKLzAp3BigXJp4j8940bYB0JFHI--7siqQ4WEa8r759RVv_MPizw&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ8tMDegQIChAS",
"10": "https://www.google.com/search?q=Go+programming+language+version+1.0+release+date&sca_esv=8d888c12df67f607&gl=us&hl=en&ei=0SCjaNeBJ7PZ5OUPxIW6qQ4&start=90&sa=N&sstk=Ac65TH4GMu9hunGkMTuKViJxVZFX5vVYXMpnHXx1et4fgOJFfBaKLzAp3BigXJp4j8940bYB0JFHI--7siqQ4WEa8r759RVv_MPizw&ved=2ahUKEwiXrpucspSPAxWzLLkGHcSCLuUQ8tMDegQIChAU"
}
},
"serpapi_pagination": {
"current": 1,
"next_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=10",
"next": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=10",
"other_pages": {
"2": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=10",
"3": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=20",
"4": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=30",
"5": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=40",
"6": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=50",
"7": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=60",
"8": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=70",
"9": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=80",
"10": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google_domain=google.com&hl=en&q=Go+programming+language+version+1.0+release+date&start=90"
}
}
}1662 1620
POST https://api.openai.com/v1/chat/completions HTTP/1.1
Host: api.openai.com
User-Agent: langchaingo-httprr
Content-Length: 1459
Authorization: Bearer test-api-key
Content-Type: application/json
{"model":"gpt-4","messages":[{"role":"system","content":"you are a helpful assistant"},{"role":"user","content":"please be strict"},{"role":"user","content":"when was the Go programming language tagged version 1.0?"},{"role":"assistant","content":"","tool_calls":[{"id":"call_xBZmyTROTl3UDnkHo7ViHPJ6","type":"function","function":{"name":"GoogleSearch","arguments":"Go programming language version 1.0 release date"}}]},{"role":"tool","content":"Its designers were primarily motivated by their shared dislike of C++. Go was publicly announced in November 2009, and version 1.0 was released in March 2012. ...","tool_call_id":"call_xBZmyTROTl3UDnkHo7ViHPJ6"}],"temperature":0,"tools":[{"type":"function","function":{"name":"GoogleSearch","description":"\n\t\"A wrapper around Google Search. \"\n\t\"Useful for when you need to answer questions about current events. \"\n\t\"Always one of the first options when you need to find information on internet\"\n\t\"Input should be a search query.\"","parameters":{"properties":{"__arg1":{"title":"__arg1","type":"string"}},"required":["__arg1"],"type":"object"}}},{"type":"function","function":{"name":"calculator","description":"Useful for getting the result of a math expression. \n\tThe input to this tool should be a valid mathematical expression that could be executed by a starlark evaluator.","parameters":{"properties":{"__arg1":{"title":"__arg1","type":"string"}},"required":["__arg1"],"type":"object"}}}]}HTTP/2.0 200 OK
Content-Length: 853
Access-Control-Expose-Headers: X-Request-ID
Alt-Svc: h3=":443"; ma=86400
Cf-Cache-Status: DYNAMIC
Content-Type: application/json
Date: Mon, 18 Aug 2025 12:47:16 GMT
Openai-Organization: lcgo-tst
Openai-Processing-Ms: 917
Openai-Project: proj_qm9GQ7k7ESiwosypKZaDuaoq
Openai-Version: 2020-10-01
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 938
X-Ratelimit-Limit-Requests: 10000
X-Ratelimit-Limit-Tokens: 1000000
X-Ratelimit-Remaining-Requests: 9999
X-Ratelimit-Remaining-Tokens: 999928
X-Ratelimit-Reset-Requests: 6ms
X-Ratelimit-Reset-Tokens: 4ms
X-Request-Id: req_9ac4b1355e5849cc91f0be7c4cd192b3
{
"id": "chatcmpl-C5tYZx9r7W5CnzJ8jMKVXlMPxFbMD",
"object": "chat.completion",
"created": 1755521235,
"model": "gpt-4-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The Go programming language version 1.0 was released in March 2012.",
"refusal": null,
"annotations": []
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 228,
"completion_tokens": 18,
"total_tokens": 246,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": null
}
================================================
FILE: agents/testdata/TestOpenAIFunctionsAgentComplexCalculation.httprr
================================================
httprr trace v1
855 2111
POST https://api.openai.com/v1/chat/completions HTTP/1.1
Host: api.openai.com
User-Agent: langchaingo-httprr
Content-Length: 653
Authorization: Bearer test-api-key
Content-Type: application/json
{"model":"gpt-4o","messages":[{"role":"system","content":"You are a helpful math assistant."},{"role":"user","content":"Please show your work step by step."},{"role":"user","content":"If I have 3 groups of 7 items, and I add 9 more items, how many items do I have in total?"}],"temperature":0,"tools":[{"type":"function","function":{"name":"calculator","description":"Useful for getting the result of a math expression. \n\tThe input to this tool should be a valid mathematical expression that could be executed by a starlark evaluator.","parameters":{"properties":{"__arg1":{"title":"__arg1","type":"string"}},"required":["__arg1"],"type":"object"}}}]}HTTP/2.0 200 OK
Content-Length: 1339
Access-Control-Expose-Headers: X-Request-ID
Alt-Svc: h3=":443"; ma=86400
Cf-Cache-Status: DYNAMIC
Content-Type: application/json
Date: Mon, 18 Aug 2025 12:47:13 GMT
Openai-Organization: lcgo-tst
Openai-Processing-Ms: 4119
Openai-Project: proj_qm9GQ7k7ESiwosypKZaDuaoq
Openai-Version: 2020-10-01
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 4213
X-Ratelimit-Limit-Requests: 10000
X-Ratelimit-Limit-Tokens: 30000000
X-Ratelimit-Remaining-Requests: 9999
X-Ratelimit-Remaining-Tokens: 29999956
X-Ratelimit-Reset-Requests: 6ms
X-Ratelimit-Reset-Tokens: 0s
X-Request-Id: req_6884fae54e3344799952232832c03e3d
{
"id": "chatcmpl-C5tYTqCwufXop3C3uD0VRj3o0DyYc",
"object": "chat.completion",
"created": 1755521229,
"model": "gpt-4o-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "To find the total number of items, we can break down the problem into two main steps:\n\n1. **Calculate the total number of items in the 3 groups of 7 items each.**\n\n Each group has 7 items, and there are 3 groups. So, we multiply the number of items per group by the number of groups:\n \\[\n 3 \\times 7 = 21\n \\]\n\n2. **Add the 9 additional items to the total from step 1.**\n\n We take the total from the groups and add the 9 more items:\n \\[\n 21 + 9 = 30\n \\]\n\nTherefore, the total number of items is 30.",
"refusal": null,
"annotations": []
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 122,
"completion_tokens": 150,
"total_tokens": 272,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": "fp_80956533cb"
}
================================================
FILE: agents/testdata/TestOpenAIFunctionsAgentWithHTTPRR.httprr
================================================
httprr trace v1
754 1852
POST https://api.openai.com/v1/chat/completions HTTP/1.1
Host: api.openai.com
User-Agent: langchaingo-httprr
Content-Length: 552
Authorization: Bearer test-api-key
Content-Type: application/json
{"model":"gpt-4o","messages":[{"role":"system","content":"You are a helpful assistant that can perform calculations."},{"role":"user","content":"What is 15 multiplied by 4?"}],"temperature":0,"tools":[{"type":"function","function":{"name":"calculator","description":"Useful for getting the result of a math expression. \n\tThe input to this tool should be a valid mathematical expression that could be executed by a starlark evaluator.","parameters":{"properties":{"__arg1":{"title":"__arg1","type":"string"}},"required":["__arg1"],"type":"object"}}}]}HTTP/2.0 200 OK
Content-Length: 1082
Access-Control-Expose-Headers: X-Request-ID
Alt-Svc: h3=":443"; ma=86400
Cf-Cache-Status: DYNAMIC
Content-Type: application/json
Date: Mon, 18 Aug 2025 12:47:09 GMT
Openai-Organization: lcgo-tst
Openai-Processing-Ms: 504
Openai-Project: proj_qm9GQ7k7ESiwosypKZaDuaoq
Openai-Version: 2020-10-01
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 587
X-Ratelimit-Limit-Requests: 10000
X-Ratelimit-Limit-Tokens: 30000000
X-Ratelimit-Remaining-Requests: 9999
X-Ratelimit-Remaining-Tokens: 29999975
X-Ratelimit-Reset-Requests: 6ms
X-Ratelimit-Reset-Tokens: 0s
X-Request-Id: req_548c168a502842bb94fd5e2391640450
{
"id": "chatcmpl-C5tYT1lejU5HDjVQBLTAyqHWGgSjU",
"object": "chat.completion",
"created": 1755521229,
"model": "gpt-4o-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_sgvhmmuASadOaDtd93TmrUsY",
"type": "function",
"function": {
"name": "calculator",
"arguments": "{\"__arg1\":\"15 * 4\"}"
}
}
],
"refusal": null,
"annotations": []
},
"logprobs": null,
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 94,
"completion_tokens": 19,
"total_tokens": 113,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": "fp_80956533cb"
}
992 1598
POST https://api.openai.com/v1/chat/completions HTTP/1.1
Host: api.openai.com
User-Agent: langchaingo-httprr
Content-Length: 790
Authorization: Bearer test-api-key
Content-Type: application/json
{"model":"gpt-4o","messages":[{"role":"system","content":"You are a helpful assistant that can perform calculations."},{"role":"user","content":"What is 15 multiplied by 4?"},{"role":"assistant","content":"","tool_calls":[{"id":"call_sgvhmmuASadOaDtd93TmrUsY","type":"function","function":{"name":"calculator","arguments":"15 * 4"}}]},{"role":"tool","content":"60","tool_call_id":"call_sgvhmmuASadOaDtd93TmrUsY"}],"temperature":0,"tools":[{"type":"function","function":{"name":"calculator","description":"Useful for getting the result of a math expression. \n\tThe input to this tool should be a valid mathematical expression that could be executed by a starlark evaluator.","parameters":{"properties":{"__arg1":{"title":"__arg1","type":"string"}},"required":["__arg1"],"type":"object"}}}]}HTTP/2.0 200 OK
Content-Length: 829
Access-Control-Expose-Headers: X-Request-ID
Alt-Svc: h3=":443"; ma=86400
Cf-Cache-Status: DYNAMIC
Content-Type: application/json
Date: Mon, 18 Aug 2025 12:47:11 GMT
Openai-Organization: lcgo-tst
Openai-Processing-Ms: 419
Openai-Project: proj_qm9GQ7k7ESiwosypKZaDuaoq
Openai-Version: 2020-10-01
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 502
X-Ratelimit-Limit-Requests: 10000
X-Ratelimit-Limit-Tokens: 30000000
X-Ratelimit-Remaining-Requests: 9999
X-Ratelimit-Remaining-Tokens: 29999973
X-Ratelimit-Reset-Requests: 6ms
X-Ratelimit-Reset-Tokens: 0s
X-Request-Id: req_ed82ddd09b52482fbaa51e7138991c8e
{
"id": "chatcmpl-C5tYVx3jHrQWYj301DQkDQhBsSXbN",
"object": "chat.completion",
"created": 1755521231,
"model": "gpt-4o-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "15 multiplied by 4 is 60.",
"refusal": null,
"annotations": []
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 115,
"completion_tokens": 10,
"total_tokens": 125,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": "fp_80956533cb"
}
================================================
FILE: callbacks/agent_final_stream.go
================================================
package callbacks
import (
"context"
"strings"
)
// DefaultKeywords is map of the agents final out prefix keywords.
//
//nolint:all
var DefaultKeywords = []string{"Final Answer:", "Final:", "AI:"}
type AgentFinalStreamHandler struct {
SimpleHandler
egress chan []byte
Keywords []string
LastTokens string
KeywordDetected bool
PrintOutput bool
}
var _ Handler = &AgentFinalStreamHandler{}
// NewFinalStreamHandler creates a new instance of the AgentFinalStreamHandler struct.
//
// It accepts a variadic number of strings as keywords. If any keywords are provided,
// the DefaultKeywords variable is updated with the provided keywords.
//
// DefaultKeywords is map of the agents final out prefix keywords.
//
// The function returns a pointer to the created AgentFinalStreamHandler struct.
func NewFinalStreamHandler(keywords ...string) *AgentFinalStreamHandler {
if len(keywords) > 0 {
DefaultKeywords = keywords
}
return &AgentFinalStreamHandler{
egress: make(chan []byte),
Keywords: DefaultKeywords,
}
}
// GetEgress returns the egress channel of the AgentFinalStreamHandler.
//
// It does not take any parameters.
// It returns a channel of type []byte.
func (handler *AgentFinalStreamHandler) GetEgress() chan []byte {
return handler.egress
}
// ReadFromEgress reads data from the egress channel and invokes the provided
// callback function with each chunk of data.
//
// The callback function receives two parameters:
// - ctx: the context.Context object for the egress operation.
// - chunk: a byte slice representing a chunk of data from the egress channel.
func (handler *AgentFinalStreamHandler) ReadFromEgress(
ctx context.Context,
callback func(ctx context.Context, chunk []byte),
) {
go func() {
defer close(handler.egress)
for data := range handler.egress {
callback(ctx, data)
}
}()
}
// HandleStreamingFunc implements the callback interface that handles the streaming
// of data in the AgentFinalStreamHandler. The handler reads the incoming data and checks for the
// agents final output keywords, ie, `Final Answer:`, `Final:`, `AI:`. Upon detection of
// the keyword, it starst to stream the agents final output to the egress channel.
//
// It takes in the context and a chunk of bytes as parameters.
// There is no return type for this function.
func (handler *AgentFinalStreamHandler) HandleStreamingFunc(_ context.Context, chunk []byte) {
chunkStr := string(chunk)
handler.LastTokens += chunkStr
var detectedKeyword string
// Buffer the last few chunks to match the longest keyword size
var longestSize int
for _, k := range handler.Keywords {
if len(k) > longestSize {
longestSize = len(k)
}
}
// Check for keywords
for _, k := range DefaultKeywords {
if strings.Contains(handler.LastTokens, k) {
handler.KeywordDetected = true
detectedKeyword = k
}
}
if len(handler.LastTokens) > longestSize {
handler.LastTokens = handler.LastTokens[len(handler.LastTokens)-longestSize:]
}
// Check for colon and set print mode.
if handler.KeywordDetected && !handler.PrintOutput {
// remove any other strings before the final answer
chunk = []byte(filterFinalString(chunkStr, detectedKeyword))
handler.PrintOutput = true
}
// Print the final output after the detection of keyword.
if handler.PrintOutput {
handler.egress <- chunk
}
}
func filterFinalString(chunkStr, keyword string) string {
chunkStr = strings.TrimLeft(chunkStr, " ")
index := strings.Index(chunkStr, keyword)
switch {
case index != -1:
chunkStr = chunkStr[index+len(keyword):]
case strings.HasPrefix(chunkStr, ":"):
chunkStr = strings.TrimPrefix(chunkStr, ":")
}
return strings.TrimLeft(chunkStr, " ")
}
================================================
FILE: callbacks/agent_final_stream_test.go
================================================
package callbacks
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestFilterFinalString(t *testing.T) {
t.Parallel()
cases := []struct {
keyword string
inputStr string
expected string
}{
{
keyword: "Final Answer:",
inputStr: "This is a correct final string.",
expected: "This is a correct final string.",
},
{
keyword: "Final Answer:",
inputStr: " some other text above.\nFinal Answer: This is a correct final string.",
expected: "This is a correct final string.",
},
{
keyword: "Final Answer:",
inputStr: " another text before. Final Answer: This is a correct final string.",
expected: "This is a correct final string.",
},
{
keyword: "Final Answer:",
inputStr: ` : This is a correct final string.`,
expected: "This is a correct final string.",
},
{
keyword: "Customed KeyWord_2:",
inputStr: " some other text above.\nSome Customed KeyWord_2: This is a correct final string.",
expected: "This is a correct final string.",
},
{
keyword: "Customed KeyWord_$#@-123:",
inputStr: " another text before keyword. Some Customed KeyWord_$#@-123: This is a correct final string.",
expected: "This is a correct final string.",
},
}
for _, tc := range cases {
filteredStr := filterFinalString(tc.inputStr, tc.keyword)
require.Equal(t, tc.expected, filteredStr)
}
}
================================================
FILE: callbacks/callbacks.go
================================================
package callbacks
import (
"context"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/schema"
)
// Handler is the interface that allows for hooking into specific parts of an
// LLM application.
//
//nolint:all
type Handler interface {
HandleText(ctx context.Context, text string)
HandleLLMStart(ctx context.Context, prompts []string)
HandleLLMGenerateContentStart(ctx context.Context, ms []llms.MessageContent)
HandleLLMGenerateContentEnd(ctx context.Context, res *llms.ContentResponse)
HandleLLMError(ctx context.Context, err error)
HandleChainStart(ctx context.Context, inputs map[string]any)
HandleChainEnd(ctx context.Context, outputs map[string]any)
HandleChainError(ctx context.Context, err error)
HandleToolStart(ctx context.Context, input string)
HandleToolEnd(ctx context.Context, output string)
HandleToolError(ctx context.Context, err error)
HandleAgentAction(ctx context.Context, action schema.AgentAction)
HandleAgentFinish(ctx context.Context, finish schema.AgentFinish)
HandleRetrieverStart(ctx context.Context, query string)
HandleRetrieverEnd(ctx context.Context, query string, documents []schema.Document)
HandleStreamingFunc(ctx context.Context, chunk []byte)
}
// HandlerHaver is an interface used to get callbacks handler.
type HandlerHaver interface {
GetCallbackHandler() Handler
}
================================================
FILE: callbacks/callbacks_unit_test.go
================================================
package callbacks
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/schema"
)
// Unit tests that don't require external dependencies
type testHandlerHaver struct {
handler Handler
}
func (t *testHandlerHaver) GetCallbackHandler() Handler {
return t.handler
}
type mockHandler struct {
mock.Mock
}
func (m *mockHandler) HandleText(ctx context.Context, text string) {
m.Called(ctx, text)
}
func (m *mockHandler) HandleLLMStart(ctx context.Context, prompts []string) {
m.Called(ctx, prompts)
}
func (m *mockHandler) HandleLLMGenerateContentStart(ctx context.Context, ms []llms.MessageContent) {
m.Called(ctx, ms)
}
func (m *mockHandler) HandleLLMGenerateContentEnd(ctx context.Context, res *llms.ContentResponse) {
m.Called(ctx, res)
}
func (m *mockHandler) HandleLLMError(ctx context.Context, err error) {
m.Called(ctx, err)
}
func (m *mockHandler) HandleChainStart(ctx context.Context, inputs map[string]any) {
m.Called(ctx, inputs)
}
func (m *mockHandler) HandleChainEnd(ctx context.Context, outputs map[string]any) {
m.Called(ctx, outputs)
}
func (m *mockHandler) HandleChainError(ctx context.Context, err error) {
m.Called(ctx, err)
}
func (m *mockHandler) HandleToolStart(ctx context.Context, input string) {
m.Called(ctx, input)
}
func (m *mockHandler) HandleToolEnd(ctx context.Context, output string) {
m.Called(ctx, output)
}
func (m *mockHandler) HandleToolError(ctx context.Context, err error) {
m.Called(ctx, err)
}
func (m *mockHandler) HandleAgentAction(ctx context.Context, action schema.AgentAction) {
m.Called(ctx, action)
}
func (m *mockHandler) HandleAgentFinish(ctx context.Context, finish schema.AgentFinish) {
m.Called(ctx, finish)
}
func (m *mockHandler) HandleRetrieverStart(ctx context.Context, query string) {
m.Called(ctx, query)
}
func (m *mockHandler) HandleRetrieverEnd(ctx context.Context, query string, documents []schema.Document) {
m.Called(ctx, query, documents)
}
func (m *mockHandler) HandleStreamingFunc(ctx context.Context, chunk []byte) {
m.Called(ctx, chunk)
}
func TestSimpleHandler(t *testing.T) {
t.Parallel()
// Test that SimpleHandler implements Handler interface
var _ Handler = SimpleHandler{}
ctx := context.Background()
handler := SimpleHandler{}
// Test all methods run without error (they're all no-ops)
handler.HandleText(ctx, "test")
handler.HandleLLMStart(ctx, []string{"prompt"})
handler.HandleLLMGenerateContentStart(ctx, []llms.MessageContent{})
handler.HandleLLMGenerateContentEnd(ctx, &llms.ContentResponse{})
handler.HandleLLMError(ctx, assert.AnError)
handler.HandleChainStart(ctx, map[string]any{"input": "value"})
handler.HandleChainEnd(ctx, map[string]any{"output": "value"})
handler.HandleChainError(ctx, assert.AnError)
handler.HandleToolStart(ctx, "tool input")
handler.HandleToolEnd(ctx, "tool output")
handler.HandleToolError(ctx, assert.AnError)
handler.HandleAgentAction(ctx, schema.AgentAction{})
handler.HandleAgentFinish(ctx, schema.AgentFinish{})
handler.HandleRetrieverStart(ctx, "query")
handler.HandleRetrieverEnd(ctx, "query", []schema.Document{})
handler.HandleStreamingFunc(ctx, []byte("chunk"))
// No assertions needed - if we get here, all methods executed without panic
}
func TestCombiningHandler(t *testing.T) {
t.Parallel()
// Test that CombiningHandler implements Handler interface
var _ Handler = CombiningHandler{}
ctx := context.Background()
t.Run("empty callbacks", func(t *testing.T) {
handler := CombiningHandler{Callbacks: []Handler{}}
// All methods should work with empty callbacks
handler.HandleText(ctx, "test")
handler.HandleLLMStart(ctx, []string{"prompt"})
handler.HandleLLMGenerateContentStart(ctx, []llms.MessageContent{})
handler.HandleLLMGenerateContentEnd(ctx, &llms.ContentResponse{})
handler.HandleLLMError(ctx, assert.AnError)
handler.HandleChainStart(ctx, map[string]any{"input": "value"})
handler.HandleChainEnd(ctx, map[string]any{"output": "value"})
handler.HandleChainError(ctx, assert.AnError)
handler.HandleToolStart(ctx, "tool input")
handler.HandleToolEnd(ctx, "tool output")
handler.HandleToolError(ctx, assert.AnError)
handler.HandleAgentAction(ctx, schema.AgentAction{})
handler.HandleAgentFinish(ctx, schema.AgentFinish{})
handler.HandleRetrieverStart(ctx, "query")
handler.HandleRetrieverEnd(ctx, "query", []schema.Document{})
handler.HandleStreamingFunc(ctx, []byte("chunk"))
})
t.Run("single callback", func(t *testing.T) {
mock1 := &mockHandler{}
handler := CombiningHandler{Callbacks: []Handler{mock1}}
// Set up expectations
mock1.On("HandleText", ctx, "test")
mock1.On("HandleLLMStart", ctx, []string{"prompt"})
mock1.On("HandleLLMGenerateContentStart", ctx, []llms.MessageContent{})
mock1.On("HandleLLMGenerateContentEnd", ctx, &llms.ContentResponse{})
mock1.On("HandleLLMError", ctx, assert.AnError)
mock1.On("HandleChainStart", ctx, map[string]any{"input": "value"})
mock1.On("HandleChainEnd", ctx, map[string]any{"output": "value"})
mock1.On("HandleChainError", ctx, assert.AnError)
mock1.On("HandleToolStart", ctx, "tool input")
mock1.On("HandleToolEnd", ctx, "tool output")
mock1.On("HandleToolError", ctx, assert.AnError)
mock1.On("HandleAgentAction", ctx, schema.AgentAction{})
mock1.On("HandleAgentFinish", ctx, schema.AgentFinish{})
mock1.On("HandleRetrieverStart", ctx, "query")
mock1.On("HandleRetrieverEnd", ctx, "query", []schema.Document{})
mock1.On("HandleStreamingFunc", ctx, []byte("chunk"))
// Call all methods
handler.HandleText(ctx, "test")
handler.HandleLLMStart(ctx, []string{"prompt"})
handler.HandleLLMGenerateContentStart(ctx, []llms.MessageContent{})
handler.HandleLLMGenerateContentEnd(ctx, &llms.ContentResponse{})
handler.HandleLLMError(ctx, assert.AnError)
handler.HandleChainStart(ctx, map[string]any{"input": "value"})
handler.HandleChainEnd(ctx, map[string]any{"output": "value"})
handler.HandleChainError(ctx, assert.AnError)
handler.HandleToolStart(ctx, "tool input")
handler.HandleToolEnd(ctx, "tool output")
handler.HandleToolError(ctx, assert.AnError)
handler.HandleAgentAction(ctx, schema.AgentAction{})
handler.HandleAgentFinish(ctx, schema.AgentFinish{})
handler.HandleRetrieverStart(ctx, "query")
handler.HandleRetrieverEnd(ctx, "query", []schema.Document{})
handler.HandleStreamingFunc(ctx, []byte("chunk"))
// Verify all expectations were met
mock1.AssertExpectations(t)
})
t.Run("multiple callbacks", func(t *testing.T) {
mock1 := &mockHandler{}
mock2 := &mockHandler{}
handler := CombiningHandler{Callbacks: []Handler{mock1, mock2}}
// Set up expectations for both mocks
for _, m := range []*mockHandler{mock1, mock2} {
m.On("HandleText", ctx, "test")
m.On("HandleChainStart", ctx, map[string]any{"input": "value"})
m.On("HandleToolError", ctx, assert.AnError)
}
// Call methods
handler.HandleText(ctx, "test")
handler.HandleChainStart(ctx, map[string]any{"input": "value"})
handler.HandleToolError(ctx, assert.AnError)
// Verify all expectations were met
mock1.AssertExpectations(t)
mock2.AssertExpectations(t)
})
}
func TestCombiningHandlerStructure(t *testing.T) {
t.Parallel()
// Test struct initialization
handler := CombiningHandler{
Callbacks: []Handler{
SimpleHandler{},
SimpleHandler{},
},
}
assert.Len(t, handler.Callbacks, 2)
// Test that we can access the callbacks
for _, callback := range handler.Callbacks {
assert.NotNil(t, callback)
// Verify each callback implements Handler interface
assert.Implements(t, (*Handler)(nil), callback)
}
}
func TestHandlerInterfaceCompleteness(t *testing.T) {
t.Parallel()
// Verify that our mock handler implements all methods of the Handler interface
var _ Handler = &mockHandler{}
// Verify that SimpleHandler implements all methods of the Handler interface
var _ Handler = SimpleHandler{}
// Verify that CombiningHandler implements all methods of the Handler interface
var _ Handler = CombiningHandler{}
}
func TestHandlerHaverInterface(t *testing.T) {
t.Parallel()
// Verify interface implementation
var _ HandlerHaver = &testHandlerHaver{}
handler := SimpleHandler{}
haver := &testHandlerHaver{handler: handler}
retrieved := haver.GetCallbackHandler()
assert.Equal(t, handler, retrieved)
}
func TestComplexCombiningScenario(t *testing.T) {
t.Parallel()
ctx := context.Background()
// Create a complex scenario with nested combining handlers
mock1 := &mockHandler{}
mock2 := &mockHandler{}
innerCombining := CombiningHandler{Callbacks: []Handler{mock1}}
outerCombining := CombiningHandler{Callbacks: []Handler{innerCombining, mock2}}
// Set up expectations
mock1.On("HandleText", ctx, "nested test")
mock2.On("HandleText", ctx, "nested test")
// Call method
outerCombining.HandleText(ctx, "nested test")
// Verify expectations
mock1.AssertExpectations(t)
mock2.AssertExpectations(t)
}
func TestCombiningHandlerWithMixedTypes(t *testing.T) {
t.Parallel()
ctx := context.Background()
// Test combining different handler types
mock := &mockHandler{}
simple := SimpleHandler{}
handler := CombiningHandler{
Callbacks: []Handler{mock, simple},
}
mock.On("HandleLLMError", ctx, assert.AnError)
// This should call the mock and the simple handler (which is a no-op)
handler.HandleLLMError(ctx, assert.AnError)
mock.AssertExpectations(t)
}
func TestCallbackTypes(t *testing.T) {
t.Parallel()
ctx := context.Background()
tests := []struct {
name string
callFunc func(Handler)
}{
{
name: "HandleText",
callFunc: func(h Handler) {
h.HandleText(ctx, "sample text")
},
},
{
name: "HandleLLMStart",
callFunc: func(h Handler) {
h.HandleLLMStart(ctx, []string{"prompt1", "prompt2"})
},
},
{
name: "HandleLLMGenerateContentStart",
callFunc: func(h Handler) {
h.HandleLLMGenerateContentStart(ctx, []llms.MessageContent{
{Role: llms.ChatMessageTypeHuman, Parts: []llms.ContentPart{llms.TextPart("test")}},
})
},
},
{
name: "HandleLLMGenerateContentEnd",
callFunc: func(h Handler) {
h.HandleLLMGenerateContentEnd(ctx, &llms.ContentResponse{
Choices: []*llms.ContentChoice{{Content: "response"}},
})
},
},
{
name: "HandleAgentAction",
callFunc: func(h Handler) {
h.HandleAgentAction(ctx, schema.AgentAction{
Tool: "calculator",
ToolInput: "2+2",
Log: "Using calculator",
})
},
},
{
name: "HandleAgentFinish",
callFunc: func(h Handler) {
h.HandleAgentFinish(ctx, schema.AgentFinish{
ReturnValues: map[string]any{"result": "4"},
Log: "Calculation complete",
})
},
},
{
name: "HandleRetrieverEnd",
callFunc: func(h Handler) {
h.HandleRetrieverEnd(ctx, "search query", []schema.Document{
{PageContent: "document content", Metadata: map[string]any{"source": "test"}},
})
},
},
{
name: "HandleStreamingFunc",
callFunc: func(h Handler) {
h.HandleStreamingFunc(ctx, []byte("streaming chunk"))
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Test with SimpleHandler (should not panic)
simple := SimpleHandler{}
tt.callFunc(simple)
// Test with CombiningHandler with empty callbacks
combining := CombiningHandler{Callbacks: []Handler{}}
tt.callFunc(combining)
// Test with CombiningHandler with SimpleHandler
combiningWithSimple := CombiningHandler{Callbacks: []Handler{simple}}
tt.callFunc(combiningWithSimple)
})
}
}
================================================
FILE: callbacks/combining.go
================================================
package callbacks
import (
"context"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/schema"
)
// CombiningHandler is a callback handler that combine multi callbacks.
type CombiningHandler struct {
Callbacks []Handler
}
var _ Handler = CombiningHandler{}
func (l CombiningHandler) HandleText(ctx context.Context, text string) {
for _, handle := range l.Callbacks {
handle.HandleText(ctx, text)
}
}
func (l CombiningHandler) HandleLLMStart(ctx context.Context, prompts []string) {
for _, handle := range l.Callbacks {
handle.HandleLLMStart(ctx, prompts)
}
}
func (l CombiningHandler) HandleLLMGenerateContentStart(ctx context.Context, ms []llms.MessageContent) {
for _, handle := range l.Callbacks {
handle.HandleLLMGenerateContentStart(ctx, ms)
}
}
func (l CombiningHandler) HandleLLMGenerateContentEnd(ctx context.Context, res *llms.ContentResponse) {
for _, handle := range l.Callbacks {
handle.HandleLLMGenerateContentEnd(ctx, res)
}
}
func (l CombiningHandler) HandleChainStart(ctx context.Context, inputs map[string]any) {
for _, handle := range l.Callbacks {
handle.HandleChainStart(ctx, inputs)
}
}
func (l CombiningHandler) HandleChainEnd(ctx context.Context, outputs map[string]any) {
for _, handle := range l.Callbacks {
handle.HandleChainEnd(ctx, outputs)
}
}
func (l CombiningHandler) HandleToolStart(ctx context.Context, input string) {
for _, handle := range l.Callbacks {
handle.HandleToolStart(ctx, input)
}
}
func (l CombiningHandler) HandleToolEnd(ctx context.Context, output string) {
for _, handle := range l.Callbacks {
handle.HandleToolEnd(ctx, output)
}
}
func (l CombiningHandler) HandleAgentAction(ctx context.Context, action schema.AgentAction) {
for _, handle := range l.Callbacks {
handle.HandleAgentAction(ctx, action)
}
}
func (l CombiningHandler) HandleAgentFinish(ctx context.Context, finish schema.AgentFinish) {
for _, handle := range l.Callbacks {
handle.HandleAgentFinish(ctx, finish)
}
}
func (l CombiningHandler) HandleRetrieverStart(ctx context.Context, query string) {
for _, handle := range l.Callbacks {
handle.HandleRetrieverStart(ctx, query)
}
}
func (l CombiningHandler) HandleRetrieverEnd(ctx context.Context, query string, documents []schema.Document) {
for _, handle := range l.Callbacks {
handle.HandleRetrieverEnd(ctx, query, documents)
}
gitextract_818zmpj_/
├── .gitattributes
├── .github/
│ ├── FUNDING.yml
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── workflows/
│ ├── ci.yaml
│ ├── examples.yaml
│ └── publish-docs.yaml
├── .gitignore
├── .golangci-exp.yaml
├── .golangci.yaml
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── FIXES_SUMMARY.md
├── LICENSE
├── Makefile
├── README.md
├── agents/
│ ├── agents.go
│ ├── conversational.go
│ ├── conversational_test.go
│ ├── doc.go
│ ├── errors.go
│ ├── executor.go
│ ├── executor_test.go
│ ├── initialize.go
│ ├── markl_test.go
│ ├── mrkl.go
│ ├── mrkl_prompt.go
│ ├── ollama_agent_guide.md
│ ├── openai_functions_agent.go
│ ├── openai_functions_agent_test.go
│ ├── options.go
│ ├── prompts/
│ │ ├── conversational_format_instructions.txt
│ │ ├── conversational_prefix.txt
│ │ └── conversational_suffix.txt
│ └── testdata/
│ ├── TestConversationalWithMemory.httprr
│ ├── TestExecutorWithMRKLAgent.httprr
│ ├── TestExecutorWithOpenAIFunctionAgent.httprr
│ ├── TestOpenAIFunctionsAgentComplexCalculation.httprr
│ └── TestOpenAIFunctionsAgentWithHTTPRR.httprr
├── callbacks/
│ ├── agent_final_stream.go
│ ├── agent_final_stream_test.go
│ ├── callbacks.go
│ ├── callbacks_unit_test.go
│ ├── combining.go
│ ├── doc.go
│ ├── log.go
│ ├── log_stream.go
│ └── simple.go
├── chains/
│ ├── api.go
│ ├── api_test.go
│ ├── chains.go
│ ├── chains_test.go
│ ├── chains_unit_test.go
│ ├── constitution/
│ │ ├── constitutional.go
│ │ ├── constitutional_test.go
│ │ ├── principles.go
│ │ ├── prompts.go
│ │ └── testdata/
│ │ └── TestConstitutionalChain.httprr
│ ├── constitutional.go
│ ├── constitutional_test.go
│ ├── conversation.go
│ ├── conversation_test.go
│ ├── conversational_retrieval_qa.go
│ ├── conversational_retrieval_qa_test.go
│ ├── doc.go
│ ├── errors.go
│ ├── llm.go
│ ├── llm_azure_test.go
│ ├── llm_math.go
│ ├── llm_math_test.go
│ ├── llm_test.go
│ ├── map_reduce.go
│ ├── map_reduce_test.go
│ ├── map_rerank_documents.go
│ ├── map_rerank_documents_test.go
│ ├── options.go
│ ├── prompt_selector.go
│ ├── prompts/
│ │ ├── llm_api_url.txt
│ │ ├── llm_api_url_response.txt
│ │ └── llm_math.txt
│ ├── question_answering.go
│ ├── question_answering_test.go
│ ├── refine_documents.go
│ ├── retrieval_qa.go
│ ├── retrieval_qa_test.go
│ ├── sequential.go
│ ├── sequential_test.go
│ ├── sql_database.go
│ ├── sql_database_test.go
│ ├── stuff_documents.go
│ ├── stuff_documents_test.go
│ ├── summarization.go
│ ├── summarization_test.go
│ ├── testdata/
│ │ ├── TestConstitutionalChainBasic.httprr
│ │ ├── TestConversation.httprr
│ │ ├── TestConversationWithChatLLM.httprr
│ │ ├── TestConversationWithZepMemory.httprr
│ │ ├── TestLLMChain.httprr
│ │ ├── TestLLMChainAzure.httprr
│ │ ├── TestLLMChainWithGoogleAI.httprr
│ │ ├── TestLLMMath.httprr
│ │ ├── TestMapReduceQA.httprr
│ │ ├── TestMapReduceSummarization.httprr
│ │ ├── TestRefineQA.httprr
│ │ ├── TestRefineSummarization.httprr
│ │ ├── TestRetrievalQA.httprr
│ │ ├── TestRetrievalQAFromLLM.httprr
│ │ ├── TestSQLDatabaseChain_Call.httprr
│ │ ├── TestStuffDocuments.httprr
│ │ ├── TestStuffSummarization.httprr
│ │ └── mouse_story.txt
│ ├── transform.go
│ └── transform_test.go
├── doc.go
├── docs/
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── .vale.ini
│ ├── Makefile
│ ├── README.md
│ ├── babel.config.js
│ ├── code-block-loader.js
│ ├── docs/
│ │ ├── concepts/
│ │ │ ├── architecture.md
│ │ │ └── index.md
│ │ ├── contributing/
│ │ │ ├── documentation.md
│ │ │ └── index.md
│ │ ├── getting-started/
│ │ │ ├── guide-chat.mdx
│ │ │ ├── guide-mistral.mdx
│ │ │ ├── guide-ollama.mdx
│ │ │ └── guide-openai.mdx
│ │ ├── how-to/
│ │ │ ├── configure-llm-providers.md
│ │ │ └── index.md
│ │ ├── index.md
│ │ ├── modules/
│ │ │ ├── agents/
│ │ │ │ ├── agents/
│ │ │ │ │ └── index.mdx
│ │ │ │ ├── executor/
│ │ │ │ │ ├── getting-started.mdx
│ │ │ │ │ └── index.mdx
│ │ │ │ ├── index.mdx
│ │ │ │ └── tools/
│ │ │ │ └── index.mdx
│ │ │ ├── chains/
│ │ │ │ ├── index.mdx
│ │ │ │ └── llm_chain.mdx
│ │ │ ├── data_connection/
│ │ │ │ ├── document_loaders/
│ │ │ │ │ └── index.mdx
│ │ │ │ ├── index.mdx
│ │ │ │ ├── retrievers/
│ │ │ │ │ └── index.mdx
│ │ │ │ ├── text_splitters/
│ │ │ │ │ ├── examples/
│ │ │ │ │ │ └── index.mdx
│ │ │ │ │ └── index.mdx
│ │ │ │ └── vector_stores/
│ │ │ │ ├── index.mdx
│ │ │ │ └── pgvector.mdx
│ │ │ ├── memory/
│ │ │ │ ├── examples/
│ │ │ │ │ └── index.mdx
│ │ │ │ └── index.mdx
│ │ │ └── model_io/
│ │ │ ├── index.mdx
│ │ │ ├── models/
│ │ │ │ ├── chat/
│ │ │ │ │ ├── index.mdx
│ │ │ │ │ └── integrations.mdx
│ │ │ │ ├── embeddings/
│ │ │ │ │ ├── index.mdx
│ │ │ │ │ └── integrations.mdx
│ │ │ │ ├── index.mdx
│ │ │ │ └── llms/
│ │ │ │ ├── Integrations/
│ │ │ │ │ ├── fake.mdx
│ │ │ │ │ ├── groq.mdx
│ │ │ │ │ ├── huggingface.mdx
│ │ │ │ │ ├── llamafile.mdx
│ │ │ │ │ ├── local.mdx
│ │ │ │ │ ├── mistral.mdx
│ │ │ │ │ ├── openai.mdx
│ │ │ │ │ ├── vertexai.mdx
│ │ │ │ │ └── watsonx.mdx
│ │ │ │ └── index.mdx
│ │ │ ├── output_parsers/
│ │ │ │ └── index.mdx
│ │ │ └── prompts/
│ │ │ ├── index.mdx
│ │ │ └── prompt_templates/
│ │ │ ├── index.mdx
│ │ │ └── partial_values.mdx
│ │ └── tutorials/
│ │ ├── basic-chat-app.md
│ │ ├── code-reviewer.md
│ │ ├── index.md
│ │ ├── log-analyzer.md
│ │ └── smart-documentation.md
│ ├── docusaurus.config.js
│ ├── go.mod
│ ├── go.sum
│ ├── package.json
│ ├── parity_matrix.md
│ ├── search-indexer.go
│ ├── sidebars.js
│ ├── src/
│ │ ├── css/
│ │ │ └── custom.css
│ │ ├── pages/
│ │ │ └── index.js
│ │ └── theme/
│ │ ├── CodeBlock/
│ │ │ └── index.js
│ │ └── SearchBar/
│ │ ├── SearchBar.css
│ │ └── index.js
│ ├── static/
│ │ └── .nojekyll
│ └── styles/
│ └── langchaingo/
│ ├── ActiveVoice.yml
│ ├── Clarity.yml
│ ├── CodeBlockLanguage.yml
│ ├── ConsistentLists.yml
│ ├── DirectLanguage.yml
│ ├── ErrorHandling.yml
│ ├── HardcodedSecrets.yml
│ ├── Headers.yml
│ ├── IncompleteExamples.yml
│ ├── NoEmojis.yml
│ ├── PresentTense.yml
│ ├── Pronouns.yml
│ ├── Readability.yml
│ ├── Spelling.yml
│ ├── Terminology.yml
│ └── ignore.txt
├── documentloaders/
│ ├── assemblyai.go
│ ├── assemblyai_test.go
│ ├── csv.go
│ ├── csv_test.go
│ ├── directory.go
│ ├── directory_test.go
│ ├── doc.go
│ ├── documentloaders.go
│ ├── html.go
│ ├── html_test.go
│ ├── notion.go
│ ├── notion_test.go
│ ├── pdf.go
│ ├── pdf_test.go
│ ├── testdata/
│ │ ├── depth/
│ │ │ └── test2.md
│ │ ├── test.csv
│ │ ├── test.html
│ │ └── test.txt
│ ├── text.go
│ └── text_test.go
├── embeddings/
│ ├── bedrock/
│ │ ├── bedrock.go
│ │ ├── bedrock_test.go
│ │ ├── bedrock_unit_test.go
│ │ ├── options.go
│ │ ├── provider_amazon.go
│ │ └── provider_cohere.go
│ ├── cybertron/
│ │ ├── cybertron.go
│ │ ├── cybertron_test.go
│ │ ├── cybertron_unit_test.go
│ │ └── options.go
│ ├── doc.go
│ ├── embedding.go
│ ├── embedding_test.go
│ ├── example_test.go
│ ├── huggingface/
│ │ ├── huggingface.go
│ │ ├── huggingface_test.go
│ │ ├── huggingface_unit_test.go
│ │ └── options.go
│ ├── jina/
│ │ ├── jina.go
│ │ ├── jina_test.go
│ │ ├── jina_unit_test.go
│ │ └── options.go
│ ├── openai_test.go
│ ├── options.go
│ ├── testdata/
│ │ ├── TestOpenaiEmbeddings.httprr
│ │ ├── TestOpenaiEmbeddingsQueryVsDocuments.httprr
│ │ ├── TestOpenaiEmbeddingsWithAzureAPI.httprr
│ │ ├── TestOpenaiEmbeddingsWithOptions.httprr
│ │ ├── TestVertexAIPaLMEmbeddings.httprr
│ │ └── TestVertexAIPaLMEmbeddingsWithOptions.httprr
│ ├── vector_math.go
│ ├── vector_math_test.go
│ └── voyageai/
│ ├── options.go
│ ├── voyageai.go
│ ├── voyageai_test.go
│ └── voyageai_unit_test.go
├── examples/
│ ├── .gitattributes
│ ├── .update-all-to-latest.sh
│ ├── Makefile
│ ├── README.md
│ ├── anthropic-completion-example/
│ │ ├── README.md
│ │ ├── anthropic_completion_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── anthropic-extended-capabilities/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── anthropic-interleaved-thinking/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── anthropic-tool-call-example/
│ │ ├── README.md
│ │ ├── anthropic-tool-call-example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── anthropic-vision-example/
│ │ ├── README.md
│ │ ├── anthropic_vision_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── bedrock-claude3-vision-example/
│ │ ├── README.md
│ │ ├── becrock_claude3_vision_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── bedrock-provider-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── caching-llm-example/
│ │ ├── README.md
│ │ ├── caching_llm_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── chains-conversation-memory-sqlite/
│ │ ├── README.md
│ │ ├── chains_conversation_memory_sqlite.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── chroma-vectorstore-example/
│ │ ├── README.md
│ │ ├── chroma_vectorstore_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── cohere-llm-example/
│ │ ├── README.md
│ │ ├── cohere_completion_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── cybertron-embedding-example/
│ │ ├── README.md
│ │ ├── cybertron-embedding.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── deepseek-completion-example/
│ │ ├── deepseek-completion-example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── document-qa-example/
│ │ ├── README.md
│ │ ├── document_qa.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── ernie-chat-example/
│ │ ├── README.md
│ │ ├── ernie_chat_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── ernie-completion-example/
│ │ ├── README.md
│ │ ├── ernie_completion_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── ernie-function-call-example/
│ │ ├── README.md
│ │ ├── ernie_function_call_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── google-alloydb-chat-message-history-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── google_alloydb_chat_message_history_example.go
│ ├── google-alloydb-vectorstore-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── google_alloydb_vectorstore_example.go
│ ├── google-cloudsql-chat-message-history-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── google_cloudsql_chat_message_history_example.go
│ ├── google-cloudsql-vectorstore-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── google_cloudsql_vectorstore_example.go
│ ├── googleai-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── googleai-completion-example.go
│ ├── googleai-reasoning-caching/
│ │ └── main.go
│ ├── googleai-streaming-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── googleai-stremaing-example.go
│ ├── googleai-tool-call-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── googleai-tool-call-example.go
│ ├── groq-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── groq_completion_example.go
│ ├── huggingface-llm-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── huggingface_example.go
│ ├── huggingface-milvus-vectorstore-example/
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── Taskfile.yml
│ │ ├── docker-compose.yml
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── milvus_vectorstore_example.go
│ ├── json-mode-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── json_mode_example.go
│ ├── llamafile-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── llamafile_completion_example.go
│ ├── llm-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── llm_chain.go
│ ├── llmmath-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── llm_math_chain.go
│ ├── llmsummarization-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── llm_summarization_example.go
│ ├── local-llm-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── local_llm_example.go
│ ├── maritaca-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── maritaca-chat-example.go
│ ├── mistral-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── mistral_completion_example.go
│ ├── mistral-embedding-example/
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── mistral-embedding-example.go
│ ├── mistral-summarization-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── mistral_summarization_example.go
│ ├── mongovector-vectorstore-example/
│ │ ├── README.md
│ │ ├── docker-compose.yml
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── mongovector_vectorstore_example.go
│ ├── mrkl-agent-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── mrkl_agent.go
│ ├── nvidia-chat-completion/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── nvidia_chat_completion_example.go
│ ├── ollama-chat-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── ollama_chat_example.go
│ ├── ollama-chroma-vectorstore-example/
│ │ ├── README.md
│ │ ├── chroma_vectorstore_example.go
│ │ ├── go.mod
│ │ └── go.sum
│ ├── ollama-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── ollama_completion_example.go
│ ├── ollama-functions-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── ollama_functions_example.go
│ ├── ollama-reasoning-caching/
│ │ └── main.go
│ ├── ollama-stream-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── ollama_stream_example.go
│ ├── openai-chat-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── openai_chat_example.go
│ │ └── useragent-comparison.md
│ ├── openai-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_completion_example.go
│ ├── openai-completion-example-with-http-debugging/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_completion_example.go
│ ├── openai-embeddings-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai-embeddings-example.go
│ ├── openai-function-call-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_function_call_example.go
│ ├── openai-function-call-streaming-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_function_call_example.go
│ ├── openai-gpt4-turbo-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_gpt4_turbo.go
│ ├── openai-gpt4o-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── index.html
│ │ └── openai_gpt4o_example.go
│ ├── openai-gpt4o-mutil-content/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai-gpt4o-mutil-content.go
│ ├── openai-jsonformat-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai-jsonformat.go
│ ├── openai-o1-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai_o1_chat_example.go
│ ├── openai-readme/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openai-readme.go
│ ├── openrouter-llm-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── openrouter_llm_example.go
│ ├── perplexity-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── perplexity_completion_example.go
│ ├── pgvector-vectorstore-example/
│ │ ├── README.md
│ │ ├── create_extension.sql
│ │ ├── docker-compose.yml
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── pgvector_vectorstore_example.go
│ │ └── postgres.Dockerfile
│ ├── pinecone-vectorstore-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── pinecone_vectorstore_example.go
│ ├── postgresql-database-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── postgresql_database_chain.go
│ ├── prompt-caching/
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── prompt-template-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── qdrant-vectorstore-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── qdrant_vectorstore_example.go
│ ├── reasoning-tokens/
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ ├── redis-vectorstore-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── redis_vectorstore_example.go
│ ├── sequential-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── sequential_chain_example.go
│ ├── sql-database-chain-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── sql_database_chain.go
│ ├── tutorial-basic-chat-app/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── main.go
│ │ ├── step3_basic.go
│ │ ├── step4_interactive.go
│ │ ├── step5_memory.go
│ │ └── step6_advanced.go
│ ├── vertex-completion-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── vertex-completion-example.go
│ ├── vertex-embedding-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── vertex-embedding-example.go
│ ├── watsonx-llm-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── watsonx_example.go
│ ├── zapier-llm-example/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ └── main.go
│ └── zep-memory-chain-example/
│ ├── README.md
│ ├── go.mod
│ ├── go.sum
│ └── main.go
├── exp/
│ ├── README.md
│ └── doc.go
├── go.mod
├── go.sum
├── httputil/
│ ├── doc.go
│ ├── logging_transport.go
│ ├── transport.go
│ ├── transport_test.go
│ ├── useragent.go
│ └── useragent_test.go
├── internal/
│ ├── devtools/
│ │ ├── examples-updater/
│ │ │ └── main.go
│ │ ├── git-hooks/
│ │ │ ├── install-git-hooks.sh
│ │ │ └── pre-push
│ │ ├── lint/
│ │ │ ├── doc.go
│ │ │ └── lint.go
│ │ ├── normalize-recordings/
│ │ │ └── main.go
│ │ └── rrtool/
│ │ └── main.go
│ ├── httprr/
│ │ ├── README.md
│ │ ├── normalization_test.go
│ │ ├── rr.go
│ │ ├── rr_test.go
│ │ └── rr_unit_test.go
│ ├── imageutil/
│ │ ├── download.go
│ │ ├── download_test.go
│ │ └── download_unit_test.go
│ ├── maputil/
│ │ ├── map.go
│ │ └── map_test.go
│ ├── mongodb/
│ │ └── client.go
│ ├── setutil/
│ │ ├── set.go
│ │ └── set_test.go
│ ├── sliceutil/
│ │ ├── slice.go
│ │ └── slice_test.go
│ └── testutil/
│ └── testctr/
│ └── testctr.go
├── jsonschema/
│ ├── json.go
│ └── json_test.go
├── llms/
│ ├── anthropic/
│ │ ├── anthropicllm.go
│ │ ├── anthropicllm_option.go
│ │ ├── anthropicllm_test.go
│ │ ├── errors.go
│ │ ├── internal/
│ │ │ └── anthropicclient/
│ │ │ ├── anthropicclient.go
│ │ │ ├── anthropicclient_test.go
│ │ │ ├── completions.go
│ │ │ ├── messages.go
│ │ │ ├── messages_test.go
│ │ │ └── testdata/
│ │ │ ├── TestClient_CreateMessage.httprr
│ │ │ ├── TestClient_CreateMessageStream.httprr
│ │ │ └── TestClient_WithAnthropicBetaHeader.httprr
│ │ ├── llmtest_test.go
│ │ ├── options.go
│ │ ├── options_test.go
│ │ └── prompt_caching_test.go
│ ├── bedrock/
│ │ ├── bedrock_tool_integration_test.go
│ │ ├── bedrockllm.go
│ │ ├── bedrockllm_option.go
│ │ ├── bedrockllm_test.go
│ │ ├── bedrockllm_unit_test.go
│ │ ├── errors.go
│ │ ├── internal/
│ │ │ └── bedrockclient/
│ │ │ ├── bedrockclient.go
│ │ │ ├── bedrockclient_integration_test.go
│ │ │ ├── bedrockclient_nova_test.go
│ │ │ ├── bedrockclient_test.go
│ │ │ ├── provider_ai21.go
│ │ │ ├── provider_amazon.go
│ │ │ ├── provider_anthropic.go
│ │ │ ├── provider_cohere.go
│ │ │ ├── provider_meta.go
│ │ │ ├── provider_nova.go
│ │ │ ├── tool_call_test.go
│ │ │ └── tools.go
│ │ ├── llmtest_test.go
│ │ ├── models_list.go
│ │ ├── testdata/
│ │ │ ├── TestAmazonNova.httprr
│ │ │ ├── TestAmazonOutput.httprr
│ │ │ ├── TestAnthropicNovaImage.httprr
│ │ │ └── TestBedrockAnthropicToolCalling.httprr
│ │ └── tool_call_test.go
│ ├── cache/
│ │ ├── cache.go
│ │ ├── cache_test.go
│ │ ├── doc.go
│ │ ├── inmemory/
│ │ │ ├── inmemory.go
│ │ │ ├── inmemory_test.go
│ │ │ └── options.go
│ │ └── mocks_test.go
│ ├── chat_messages.go
│ ├── chat_messages_test.go
│ ├── cloudflare/
│ │ ├── cloudflarellm.go
│ │ ├── cloudflarellm_test.go
│ │ ├── internal/
│ │ │ └── cloudflareclient/
│ │ │ ├── api.go
│ │ │ ├── api_test.go
│ │ │ ├── client.go
│ │ │ ├── cloudflareclient_test.go
│ │ │ ├── model.go
│ │ │ └── role.go
│ │ ├── llmtest_test.go
│ │ └── options.go
│ ├── cohere/
│ │ ├── coherellm.go
│ │ ├── coherellm_option.go
│ │ ├── coherellm_test.go
│ │ ├── errors.go
│ │ ├── internal/
│ │ │ └── cohereclient/
│ │ │ ├── cohereclient.go
│ │ │ ├── cohereclient_test.go
│ │ │ └── testdata/
│ │ │ ├── TestClient_CreateGeneration.httprr
│ │ │ └── TestClient_CreateGenerationWithCustomModel.httprr
│ │ ├── llmtest_test.go
│ │ └── testdata/
│ │ ├── TestCallbacksHandler.httprr
│ │ └── TestGenerateContent.httprr
│ ├── compliance/
│ │ ├── doc.go
│ │ ├── example_test.go
│ │ └── suite.go
│ ├── count_tokens.go
│ ├── count_tokens_test.go
│ ├── doc.go
│ ├── ernie/
│ │ ├── doc.go
│ │ ├── erniellm.go
│ │ ├── erniellm_option.go
│ │ ├── erniellm_test.go
│ │ ├── internal/
│ │ │ └── ernieclient/
│ │ │ ├── chat.go
│ │ │ ├── client_unit_test.go
│ │ │ ├── ernieclient.go
│ │ │ └── ernieclient_test.go
│ │ └── llmtest_test.go
│ ├── errors.go
│ ├── errors_mapper.go
│ ├── errors_test.go
│ ├── fake/
│ │ ├── fakellm.go
│ │ ├── fakellm_test.go
│ │ └── llmtest_test.go
│ ├── generatecontent.go
│ ├── generatecontent_test.go
│ ├── googleai/
│ │ ├── README.md
│ │ ├── caching.go
│ │ ├── embeddings.go
│ │ ├── embeddings_unit_test.go
│ │ ├── errors.go
│ │ ├── googleai.go
│ │ ├── googleai_core_unit_test.go
│ │ ├── googleai_test.go
│ │ ├── googleai_unit_test.go
│ │ ├── internal/
│ │ │ ├── cmd/
│ │ │ │ └── generate-vertex.go
│ │ │ └── palmclient/
│ │ │ ├── palm_client_option.go
│ │ │ ├── palmclient.go
│ │ │ └── palmclient_unit_test.go
│ │ ├── llmtest_test.go
│ │ ├── new.go
│ │ ├── option.go
│ │ ├── palm/
│ │ │ ├── palm_llm.go
│ │ │ ├── palm_llm_option.go
│ │ │ └── palm_llm_test.go
│ │ ├── reasoning_test.go
│ │ ├── shared_test/
│ │ │ └── shared_test.go
│ │ ├── testdata/
│ │ │ ├── TestGoogleAIBatchEmbedding.httprr
│ │ │ ├── TestGoogleAICall.httprr
│ │ │ ├── TestGoogleAICreateEmbedding.httprr
│ │ │ ├── TestGoogleAIErrorHandling.httprr
│ │ │ ├── TestGoogleAIGenerateContent.httprr
│ │ │ ├── TestGoogleAIGenerateContentWithMultipleMessages.httprr
│ │ │ ├── TestGoogleAIGenerateContentWithSystemMessage.httprr
│ │ │ ├── TestGoogleAIMultiModalContent.httprr
│ │ │ ├── TestGoogleAIToolCallResponse.httprr
│ │ │ ├── TestGoogleAIWithHarmThreshold.httprr
│ │ │ ├── TestGoogleAIWithJSONMode.httprr
│ │ │ ├── TestGoogleAIWithOptions.httprr
│ │ │ ├── TestGoogleAIWithStreaming.httprr
│ │ │ └── TestGoogleAIWithTools.httprr
│ │ └── vertex/
│ │ ├── embeddings.go
│ │ ├── embeddings_test.go
│ │ ├── new.go
│ │ ├── new_test.go
│ │ ├── vertex.go
│ │ ├── vertex_test.go
│ │ └── vertex_unit_test.go
│ ├── huggingface/
│ │ ├── example_provider_test.go
│ │ ├── huggingfacellm.go
│ │ ├── huggingfacellm_option.go
│ │ ├── huggingfacellm_test.go
│ │ ├── internal/
│ │ │ └── huggingfaceclient/
│ │ │ ├── embeddings.go
│ │ │ ├── huggingfaceclient.go
│ │ │ ├── huggingfaceclient_test.go
│ │ │ ├── inference.go
│ │ │ └── testdata/
│ │ │ ├── TestClient_RunInference.httprr
│ │ │ ├── TestClient_RunInferenceText2Text.httprr
│ │ │ └── TestClient_RunInferenceWithProvider.httprr
│ │ ├── llmtest_test.go
│ │ └── testdata/
│ │ ├── TestHuggingFaceLLMStandardInference.httprr
│ │ └── TestHuggingFaceLLMWithProvider.httprr
│ ├── llamafile/
│ │ ├── internal/
│ │ │ └── llamafileclient/
│ │ │ ├── llamafileclient.go
│ │ │ ├── llamafileclient_test.go
│ │ │ └── types.go
│ │ ├── llamafilellm.go
│ │ ├── llamafilellm_test.go
│ │ ├── llmtest_test.go
│ │ └── options.go
│ ├── llms.go
│ ├── local/
│ │ ├── internal/
│ │ │ └── localclient/
│ │ │ ├── completions.go
│ │ │ ├── doc.go
│ │ │ ├── localclient.go
│ │ │ └── localclient_test.go
│ │ ├── llmtest_test.go
│ │ ├── localllm.go
│ │ ├── localllm_option.go
│ │ └── localllm_test.go
│ ├── maritaca/
│ │ ├── internal/
│ │ │ └── maritacaclient/
│ │ │ ├── maritacaclient.go
│ │ │ ├── maritacaclient_test.go
│ │ │ ├── maritacaclient_unit_test.go
│ │ │ ├── types.go
│ │ │ └── types_test.go
│ │ ├── llmtest_test.go
│ │ ├── maritaca_test.go
│ │ ├── maritacallm.go
│ │ ├── maritacallm_unit_test.go
│ │ └── options.go
│ ├── marshaling.go
│ ├── marshaling_test.go
│ ├── mistral/
│ │ ├── client_options.go
│ │ ├── errors.go
│ │ ├── llmtest_test.go
│ │ ├── mistralembed.go
│ │ ├── mistralembed_test.go
│ │ ├── mistralmodel.go
│ │ └── mistralmodel_test.go
│ ├── ollama/
│ │ ├── context_cache.go
│ │ ├── internal/
│ │ │ └── ollamaclient/
│ │ │ ├── ollamaclient.go
│ │ │ ├── ollamaclient_test.go
│ │ │ ├── testdata/
│ │ │ │ ├── TestClient_CreateEmbedding.httprr
│ │ │ │ ├── TestClient_Generate.httprr
│ │ │ │ ├── TestClient_GenerateChat.httprr
│ │ │ │ ├── TestClient_GenerateChatStream.httprr
│ │ │ │ ├── TestClient_GenerateChatWithThink.httprr
│ │ │ │ └── TestClient_GenerateStream.httprr
│ │ │ └── types.go
│ │ ├── llmtest_test.go
│ │ ├── ollama_test.go
│ │ ├── ollamallm.go
│ │ ├── options.go
│ │ ├── reasoning_test.go
│ │ └── testdata/
│ │ ├── TestCreateEmbedding.httprr
│ │ ├── TestGenerateContent.httprr
│ │ ├── TestWithFormat.httprr
│ │ ├── TestWithKeepAlive.httprr
│ │ ├── TestWithPullModel.httprr
│ │ ├── TestWithPullTimeout.httprr
│ │ ├── TestWithStreaming.httprr
│ │ └── TestWithThink.httprr
│ ├── openai/
│ │ ├── doc.go
│ │ ├── errors.go
│ │ ├── internal/
│ │ │ └── openaiclient/
│ │ │ ├── chat.go
│ │ │ ├── chat_sse_test.go
│ │ │ ├── chat_test.go
│ │ │ ├── completions.go
│ │ │ ├── embeddings.go
│ │ │ ├── marshal_test.go
│ │ │ ├── openaiclient.go
│ │ │ ├── openaiclient_test.go
│ │ │ └── testdata/
│ │ │ ├── TestClient_CreateChatCompletion.httprr
│ │ │ ├── TestClient_CreateChatCompletionStream.httprr
│ │ │ ├── TestClient_CreateEmbedding.httprr
│ │ │ ├── TestClient_CreateEmbeddingWithDimensions.httprr
│ │ │ ├── TestClient_FunctionCall.httprr
│ │ │ └── TestClient_WithResponseFormat.httprr
│ │ ├── llm.go
│ │ ├── llmtest_test.go
│ │ ├── max_tokens_test.go
│ │ ├── multicontent_test.go
│ │ ├── openaillm.go
│ │ ├── openaillm_option.go
│ │ ├── openrouter_httprr_test.go
│ │ ├── openrouter_streaming_test.go
│ │ ├── options.go
│ │ ├── options_test.go
│ │ ├── structured_output_test.go
│ │ └── testdata/
│ │ ├── TestFunctionCall.httprr
│ │ ├── TestMultiContentImage.httprr
│ │ ├── TestMultiContentText.httprr
│ │ ├── TestMultiContentTextChatSequence.httprr
│ │ ├── TestOpenRouterStreaming.httprr
│ │ ├── TestOpenRouterWithHTTPRR.httprr
│ │ ├── TestStructuredOutputFunctionCalling.httprr
│ │ ├── TestStructuredOutputObjectAndArraySchema.httprr
│ │ ├── TestStructuredOutputObjectSchema.httprr
│ │ └── TestWithStreaming.httprr
│ ├── options.go
│ ├── options_test.go
│ ├── prompt_caching.go
│ ├── prompt_caching_test.go
│ ├── prompts.go
│ ├── prompts_test.go
│ ├── reasoning.go
│ ├── reasoning_test.go
│ ├── token_utilization_test.go
│ └── watsonx/
│ ├── llmtest_test.go
│ └── watsonxllm.go
├── memory/
│ ├── alloydb/
│ │ ├── README.md
│ │ ├── chat_message_history.go
│ │ ├── chat_message_history_options.go
│ │ ├── chat_message_history_test.go
│ │ └── chat_message_history_unit_test.go
│ ├── buffer.go
│ ├── buffer_options.go
│ ├── buffer_test.go
│ ├── chat.go
│ ├── chat_options.go
│ ├── chat_test.go
│ ├── cloudsql/
│ │ ├── README.md
│ │ ├── chat_message_history.go
│ │ └── chat_message_history_options.go
│ ├── doc.go
│ ├── mongo/
│ │ ├── main_test.go
│ │ ├── mongo_chat_history.go
│ │ ├── mongo_chat_history_options.go
│ │ └── mongo_chat_history_test.go
│ ├── simple.go
│ ├── sqlite3/
│ │ ├── sqlite3_history.go
│ │ ├── sqlite3_history_options.go
│ │ └── sqlite3_history_test.go
│ ├── testdata/
│ │ ├── TestTokenBufferMemory.httprr
│ │ ├── TestTokenBufferMemoryReturnMessage.httprr
│ │ └── TestTokenBufferMemoryWithPreLoadedHistory.httprr
│ ├── token_buffer.go
│ ├── token_buffer_test.go
│ ├── window_buffer.go
│ ├── window_buffer_test.go
│ └── zep/
│ ├── zep_chat_history.go
│ ├── zep_chat_history_options.go
│ ├── zep_memory.go
│ ├── zep_memory_options.go
│ └── zep_test.go
├── outputparser/
│ ├── boolean_parser.go
│ ├── boolean_parser_test.go
│ ├── combining.go
│ ├── combining_test.go
│ ├── comma_seperated_list.go
│ ├── comma_seperated_list_test.go
│ ├── defined.go
│ ├── defined_test.go
│ ├── doc.go
│ ├── parser_additional_test.go
│ ├── regex_dict.go
│ ├── regex_dict_test.go
│ ├── regex_parser.go
│ ├── regex_parser_test.go
│ ├── simple.go
│ ├── structured.go
│ └── structured_test.go
├── prompts/
│ ├── chat_prompt.go
│ ├── chat_prompt_template.go
│ ├── chat_prompt_template_test.go
│ ├── doc.go
│ ├── example_selector.go
│ ├── examples_test.go
│ ├── few_shot.go
│ ├── few_shot_test.go
│ ├── internal/
│ │ ├── fstring/
│ │ │ ├── doc.go
│ │ │ ├── fstring.go
│ │ │ ├── fstring_test.go
│ │ │ └── parser.go
│ │ ├── loader/
│ │ │ └── secure_loader.go
│ │ └── sanitization/
│ │ └── sanitize.go
│ ├── message_prompt_template.go
│ ├── prompt_template.go
│ ├── prompt_template_test.go
│ ├── prompt_test.go
│ ├── prompts.go
│ ├── render_options.go
│ ├── security_test.go
│ ├── string_prompt.go
│ ├── templates.go
│ ├── templates_go.go
│ ├── templates_jinja2.go
│ ├── templates_test.go
│ ├── testdata/
│ │ ├── article.j2
│ │ ├── header.j2
│ │ └── main.j2
│ └── validation_test.go
├── schema/
│ ├── chat_message_history.go
│ ├── doc.go
│ ├── documents.go
│ ├── memory.go
│ ├── output_parsers.go
│ ├── retrivers.go
│ └── schema.go
├── test_all_fixes.sh
├── testing/
│ └── llmtest/
│ ├── doc.go
│ ├── llmtest.go
│ └── llmtest_test.go
├── textsplitter/
│ ├── doc.go
│ ├── markdown_splitter.go
│ ├── markdown_splitter_test.go
│ ├── options.go
│ ├── recursive_character.go
│ ├── recursive_character_test.go
│ ├── split_documents.go
│ ├── testdata/
│ │ ├── example.md
│ │ └── example_markdown_header_512.md
│ ├── text_spliter.go
│ ├── token_splitter.go
│ └── token_splitter_test.go
├── tools/
│ ├── calculator.go
│ ├── doc.go
│ ├── duckduckgo/
│ │ ├── ddg.go
│ │ ├── ddg_test.go
│ │ ├── doc.go
│ │ ├── internal/
│ │ │ └── client.go
│ │ └── testdata/
│ │ └── TestDuckDuckGoTool.httprr
│ ├── metaphor/
│ │ ├── doc.go
│ │ ├── documents.go
│ │ ├── links.go
│ │ ├── metaphor.go
│ │ ├── metaphor_test.go
│ │ └── search.go
│ ├── perplexity/
│ │ ├── doc.go
│ │ ├── perplexity.go
│ │ ├── perplexity_test.go
│ │ └── testdata/
│ │ ├── TestPerplexityTool.httprr
│ │ └── TestTool_Integration.httprr
│ ├── scraper/
│ │ ├── doc.go
│ │ ├── options.go
│ │ └── scraper.go
│ ├── serpapi/
│ │ ├── doc.go
│ │ ├── internal/
│ │ │ └── client.go
│ │ ├── options.go
│ │ ├── serpapi.go
│ │ ├── serpapi_test.go
│ │ └── testdata/
│ │ └── TestSerpAPITool.httprr
│ ├── sqldatabase/
│ │ ├── mysql/
│ │ │ ├── main_test.go
│ │ │ ├── mysql.go
│ │ │ └── mysql_test.go
│ │ ├── postgresql/
│ │ │ ├── main_test.go
│ │ │ ├── postgresql.go
│ │ │ └── postgresql_test.go
│ │ ├── sql_database.go
│ │ ├── sqlite3/
│ │ │ ├── sqlite3.go
│ │ │ └── sqlite3_test.go
│ │ └── testdata/
│ │ └── db.sql
│ ├── tool.go
│ ├── wikipedia/
│ │ ├── client.go
│ │ ├── doc.go
│ │ ├── testdata/
│ │ │ └── TestWikipedia.httprr
│ │ ├── wikipedia.go
│ │ └── wikipedia_test.go
│ └── zapier/
│ ├── description.go
│ ├── doc.go
│ ├── internal/
│ │ ├── client.go
│ │ ├── client_test.go
│ │ ├── client_unit_test.go
│ │ └── errors.go
│ ├── toolkit.go
│ ├── zapier.go
│ └── zapier_test.go
├── util/
│ ├── alloydbutil/
│ │ ├── engine.go
│ │ ├── engine_test.go
│ │ ├── options.go
│ │ └── options_test.go
│ └── cloudsqlutil/
│ ├── engine.go
│ ├── engine_test.go
│ ├── options.go
│ └── options_test.go
└── vectorstores/
├── alloydb/
│ ├── README.md
│ ├── distance_strategy.go
│ ├── main_test.go
│ ├── testdata/
│ │ ├── TestAddDocuments.httprr
│ │ ├── TestContainerApplyVectorIndexAndDropIndex.httprr
│ │ └── TestContainerIsValidIndex.httprr
│ ├── vectorstore.go
│ ├── vectorstore_container_test.go
│ ├── vectorstore_options.go
│ └── vectorstore_test.go
├── azureaisearch/
│ ├── azureaisearch.go
│ ├── azureaisearch_httprr_test.go
│ ├── azureaisearch_unit_test.go
│ ├── doc.go
│ ├── document_upload.go
│ ├── documents_search.go
│ ├── helpers.go
│ ├── helpers_http.go
│ ├── index_create.go
│ ├── index_delete.go
│ ├── index_list.go
│ ├── index_retrieve.go
│ ├── options.go
│ └── types.go
├── bedrockknowledgebases/
│ ├── bedrockknowledgebases.go
│ ├── bedrockknowledgebases_test.go
│ ├── doc.go
│ ├── ingestion.go
│ ├── options.go
│ └── s3.go
├── chroma/
│ ├── README.md
│ ├── chroma.go
│ ├── chroma_test.go
│ ├── doc.go
│ ├── embedder.go
│ ├── main_test.go
│ └── options.go
├── cloudsql/
│ ├── README.md
│ ├── distance_strategy.go
│ ├── main_test.go
│ ├── testdata/
│ │ ├── TestAddDocuments.httprr
│ │ ├── TestContainerApplyVectorIndexAndDropIndex.httprr
│ │ └── TestContainerIsValidIndex.httprr
│ ├── vectorstore.go
│ ├── vectorstore_container_test.go
│ ├── vectorstore_options.go
│ └── vectorstore_test.go
├── doc.go
├── dolt/
│ ├── doc.go
│ ├── dolt.go
│ ├── dolt_test.go
│ └── options.go
├── mariadb/
│ ├── doc.go
│ ├── main_test.go
│ ├── mariadb.go
│ ├── mariadb_test.go
│ └── options.go
├── milvus/
│ ├── main_test.go
│ ├── milvus.go
│ ├── milvus_test.go
│ ├── options.go
│ └── v2/
│ ├── README.md
│ ├── example_migration.go
│ ├── milvus.go
│ ├── milvus_test.go
│ └── options.go
├── mongovector/
│ ├── doc.go
│ ├── mock_embedder.go
│ ├── mock_llm.go
│ ├── mongovector.go
│ ├── mongovector_test.go
│ └── option.go
├── opensearch/
│ ├── doc.go
│ ├── document_indexing.go
│ ├── index_create.go
│ ├── index_delete.go
│ ├── main_test.go
│ ├── opensearch.go
│ ├── opensearch_test.go
│ ├── options.go
│ └── types.go
├── options.go
├── pgvector/
│ ├── doc.go
│ ├── main_test.go
│ ├── options.go
│ ├── pgvector.go
│ ├── pgvector_test.go
│ └── testdata/
│ └── TestDeduplicater.httprr
├── pinecone/
│ ├── doc.go
│ ├── options.go
│ ├── pinecone.go
│ ├── pinecone_test.go
│ ├── pinecone_unit_test.go
│ └── testdata/
│ └── TestPineconeStoreRest.httprr
├── qdrant/
│ ├── doc.go
│ ├── options.go
│ ├── qdrant.go
│ ├── qdrant_test.go
│ ├── qdrant_unit_test.go
│ ├── rest.go
│ └── schema.go
├── redisvector/
│ ├── doc.go
│ ├── index_schema.go
│ ├── index_schema_test.go
│ ├── index_search.go
│ ├── main_test.go
│ ├── options.go
│ ├── redis_client.go
│ ├── redis_vector.go
│ ├── redis_vector_test.go
│ └── testdata/
│ ├── TestCreateRedisVectorOptions.httprr
│ ├── schema.json
│ └── schema.yml
├── vectorstores.go
└── weaviate/
├── doc.go
├── main_test.go
├── options.go
├── testdata/
│ └── TestDeduplicater.httprr
├── weaviate.go
└── weaviate_test.go
Showing preview only (459K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (4823 symbols across 633 files)
FILE: agents/agents.go
type Agent (line 12) | type Agent interface
FILE: agents/conversational.go
constant _conversationalFinalAnswerAction (line 19) | _conversationalFinalAnswerAction = "AI:"
type ConversationalAgent (line 29) | type ConversationalAgent struct
method Plan (line 62) | func (a *ConversationalAgent) Plan(
method GetInputKeys (line 104) | func (a *ConversationalAgent) GetInputKeys() []string {
method GetOutputKeys (line 119) | func (a *ConversationalAgent) GetOutputKeys() []string {
method GetTools (line 123) | func (a *ConversationalAgent) GetTools() []tools.Tool {
method parseOutput (line 140) | func (a *ConversationalAgent) parseOutput(output string) ([]schema.Age...
function NewConversationalAgent (line 43) | func NewConversationalAgent(llm llms.Model, tools []tools.Tool, opts ......
function constructScratchPad (line 127) | func constructScratchPad(steps []schema.AgentStep) string {
function createConversationalPrompt (line 174) | func createConversationalPrompt(tools []tools.Tool, prefix, instructions...
FILE: agents/conversational_test.go
function hasExistingRecording (line 20) | func hasExistingRecording(t *testing.T) bool {
function TestConversationalWithMemory (line 28) | func TestConversationalWithMemory(t *testing.T) {
FILE: agents/errors.go
type ParserErrorHandler (line 29) | type ParserErrorHandler struct
function NewParserErrorHandler (line 36) | func NewParserErrorHandler(formatFunc func(string) string) *ParserErrorH...
FILE: agents/executor.go
constant _intermediateStepsOutputKey (line 15) | _intermediateStepsOutputKey = "intermediateSteps"
type Executor (line 18) | type Executor struct
method Call (line 50) | func (e *Executor) Call(ctx context.Context, inputValues map[string]an...
method doIteration (line 77) | func (e *Executor) doIteration( // nolint
method doAction (line 120) | func (e *Executor) doAction(
method getReturn (line 149) | func (e *Executor) getReturn(finish *schema.AgentFinish, steps []schem...
method GetInputKeys (line 159) | func (e *Executor) GetInputKeys() []string {
method GetOutputKeys (line 164) | func (e *Executor) GetOutputKeys() []string {
method GetMemory (line 168) | func (e *Executor) GetMemory() schema.Memory { //nolint:ireturn
method GetCallbackHandler (line 172) | func (e *Executor) GetCallbackHandler() callbacks.Handler { //nolint:i...
function NewExecutor (line 34) | func NewExecutor(agent Agent, opts ...Option) *Executor {
function inputsToString (line 176) | func inputsToString(inputValues map[string]any) (map[string]string, erro...
function getNameToTool (line 190) | func getNameToTool(t []tools.Tool) map[string]tools.Tool {
FILE: agents/executor_test.go
type testAgent (line 20) | type testAgent struct
method Plan (line 33) | func (a *testAgent) Plan(
method GetInputKeys (line 46) | func (a testAgent) GetInputKeys() []string {
method GetOutputKeys (line 50) | func (a testAgent) GetOutputKeys() []string {
method GetTools (line 54) | func (a *testAgent) GetTools() []tools.Tool {
function TestExecutorWithErrorHandler (line 58) | func TestExecutorWithErrorHandler(t *testing.T) {
function TestExecutorWithMRKLAgent (line 80) | func TestExecutorWithMRKLAgent(t *testing.T) {
function TestExecutorWithOpenAIFunctionAgent (line 133) | func TestExecutorWithOpenAIFunctionAgent(t *testing.T) {
type mockTool (line 194) | type mockTool struct
method Name (line 200) | func (m *mockTool) Name() string {
method Description (line 204) | func (m *mockTool) Description() string {
method Call (line 208) | func (m *mockTool) Call(_ context.Context, input string) (string, erro...
function TestExecutorTrimsObservationSuffix (line 213) | func TestExecutorTrimsObservationSuffix(t *testing.T) {
FILE: agents/initialize.go
constant _defaultMaxIterations (line 8) | _defaultMaxIterations = 5
type AgentType (line 11) | type AgentType
constant ZeroShotReactDescription (line 16) | ZeroShotReactDescription AgentType = "zeroShotReactDescription"
constant ConversationalReactDescription (line 19) | ConversationalReactDescription AgentType = "conversationalReactDescription"
function Initialize (line 26) | func Initialize(
FILE: agents/markl_test.go
function TestMRKLOutputParser (line 10) | func TestMRKLOutputParser(t *testing.T) {
FILE: agents/mrkl.go
constant _finalAnswerAction (line 17) | _finalAnswerAction = "Final Answer:"
constant _defaultOutputKey (line 18) | _defaultOutputKey = "output"
type OneShotZeroAgent (line 26) | type OneShotZeroAgent struct
method Plan (line 62) | func (a *OneShotZeroAgent) Plan(
method GetInputKeys (line 104) | func (a *OneShotZeroAgent) GetInputKeys() []string {
method GetOutputKeys (line 119) | func (a *OneShotZeroAgent) GetOutputKeys() []string {
method GetTools (line 123) | func (a *OneShotZeroAgent) GetTools() []tools.Tool {
method parseOutput (line 139) | func (a *OneShotZeroAgent) parseOutput(output string) ([]schema.AgentA...
function NewOneShotAgent (line 43) | func NewOneShotAgent(llm llms.Model, tools []tools.Tool, opts ...Option)...
function constructMrklScratchPad (line 127) | func constructMrklScratchPad(steps []schema.AgentStep) string {
FILE: agents/mrkl_prompt.go
constant _defaultMrklPrefix (line 12) | _defaultMrklPrefix = `Answer the following questions as best you can. Yo...
constant _defaultMrklFormatInstructions (line 16) | _defaultMrklFormatInstructions = `Use the following format:
constant _defaultMrklSuffix (line 27) | _defaultMrklSuffix = `Begin!
function createMRKLPrompt (line 33) | func createMRKLPrompt(tools []tools.Tool, prefix, instructions, suffix s...
function toolNames (line 47) | func toolNames(tools []tools.Tool) string {
function toolDescriptions (line 59) | func toolDescriptions(tools []tools.Tool) string {
FILE: agents/openai_functions_agent.go
constant agentScratchpad (line 17) | agentScratchpad = "agent_scratchpad"
type OpenAIFunctionsAgent (line 20) | type OpenAIFunctionsAgent struct
method functions (line 52) | func (o *OpenAIFunctionsAgent) functions() []llms.FunctionDefinition {
method Plan (line 71) | func (o *OpenAIFunctionsAgent) Plan(
method GetInputKeys (line 164) | func (o *OpenAIFunctionsAgent) GetInputKeys() []string {
method GetOutputKeys (line 179) | func (o *OpenAIFunctionsAgent) GetOutputKeys() []string {
method GetTools (line 183) | func (o *OpenAIFunctionsAgent) GetTools() []tools.Tool {
method constructScratchPad (line 199) | func (o *OpenAIFunctionsAgent) constructScratchPad(steps []schema.Agen...
method ParseOutput (line 263) | func (o *OpenAIFunctionsAgent) ParseOutput(contentResp *llms.ContentRe...
function NewOpenAIFunctionsAgent (line 37) | func NewOpenAIFunctionsAgent(llm llms.Model, tools []tools.Tool, opts .....
function createOpenAIFunctionPrompt (line 187) | func createOpenAIFunctionPrompt(opts Options) prompts.ChatPromptTemplate {
FILE: agents/openai_functions_agent_test.go
function hasExistingRecording (line 22) | func hasExistingRecording(t *testing.T) bool {
function TestOpenAIFunctionsAgentWithHTTPRR (line 30) | func TestOpenAIFunctionsAgentWithHTTPRR(t *testing.T) {
function TestOpenAIFunctionsAgentComplexCalculation (line 86) | func TestOpenAIFunctionsAgentComplexCalculation(t *testing.T) {
function TestOpenAIFunctionsAgent_ParseOutput_NilResponse (line 146) | func TestOpenAIFunctionsAgent_ParseOutput_NilResponse(t *testing.T) {
function TestOpenAIFunctionsAgent_ParseOutput_EmptyChoices (line 158) | func TestOpenAIFunctionsAgent_ParseOutput_EmptyChoices(t *testing.T) {
function TestOpenAIFunctionsAgent_ParseOutput_MultipleToolCalls (line 173) | func TestOpenAIFunctionsAgent_ParseOutput_MultipleToolCalls(t *testing.T) {
FILE: agents/options.go
type Options (line 11) | type Options struct
method getMrklPrompt (line 65) | func (co Options) getMrklPrompt(tools []tools.Tool) prompts.PromptTemp...
method getConversationalPrompt (line 78) | func (co Options) getConversationalPrompt(tools []tools.Tool) prompts....
type Option (line 30) | type Option
function executorDefaultOptions (line 32) | func executorDefaultOptions() Options {
function mrklDefaultOptions (line 40) | func mrklDefaultOptions() Options {
function conversationalDefaultOptions (line 49) | func conversationalDefaultOptions() Options {
function openAIFunctionsDefaultOptions (line 58) | func openAIFunctionsDefaultOptions() Options {
function WithMaxIterations (line 93) | func WithMaxIterations(iterations int) Option {
function WithOutputKey (line 100) | func WithOutputKey(outputKey string) Option {
function WithPromptPrefix (line 107) | func WithPromptPrefix(prefix string) Option {
function WithPromptFormatInstructions (line 115) | func WithPromptFormatInstructions(instructions string) Option {
function WithPromptSuffix (line 122) | func WithPromptSuffix(suffix string) Option {
function WithPrompt (line 129) | func WithPrompt(prompt prompts.PromptTemplate) Option {
function WithReturnIntermediateSteps (line 137) | func WithReturnIntermediateSteps() Option {
function WithMemory (line 144) | func WithMemory(m schema.Memory) Option {
function WithCallbacksHandler (line 151) | func WithCallbacksHandler(handler callbacks.Handler) Option {
function WithParserErrorHandler (line 158) | func WithParserErrorHandler(errorHandler *ParserErrorHandler) Option {
type OpenAIOption (line 164) | type OpenAIOption struct
method WithSystemMessage (line 170) | func (o OpenAIOption) WithSystemMessage(msg string) Option {
method WithExtraMessages (line 176) | func (o OpenAIOption) WithExtraMessages(extraMessages []prompts.Messag...
function NewOpenAIOption (line 166) | func NewOpenAIOption() OpenAIOption {
FILE: callbacks/agent_final_stream.go
type AgentFinalStreamHandler (line 13) | type AgentFinalStreamHandler struct
method GetEgress (line 47) | func (handler *AgentFinalStreamHandler) GetEgress() chan []byte {
method ReadFromEgress (line 57) | func (handler *AgentFinalStreamHandler) ReadFromEgress(
method HandleStreamingFunc (line 76) | func (handler *AgentFinalStreamHandler) HandleStreamingFunc(_ context....
function NewFinalStreamHandler (line 32) | func NewFinalStreamHandler(keywords ...string) *AgentFinalStreamHandler {
function filterFinalString (line 114) | func filterFinalString(chunkStr, keyword string) string {
FILE: callbacks/agent_final_stream_test.go
function TestFilterFinalString (line 9) | func TestFilterFinalString(t *testing.T) {
FILE: callbacks/callbacks.go
type Handler (line 14) | type Handler interface
type HandlerHaver (line 34) | type HandlerHaver interface
FILE: callbacks/callbacks_unit_test.go
type testHandlerHaver (line 15) | type testHandlerHaver struct
method GetCallbackHandler (line 19) | func (t *testHandlerHaver) GetCallbackHandler() Handler {
type mockHandler (line 23) | type mockHandler struct
method HandleText (line 27) | func (m *mockHandler) HandleText(ctx context.Context, text string) {
method HandleLLMStart (line 31) | func (m *mockHandler) HandleLLMStart(ctx context.Context, prompts []st...
method HandleLLMGenerateContentStart (line 35) | func (m *mockHandler) HandleLLMGenerateContentStart(ctx context.Contex...
method HandleLLMGenerateContentEnd (line 39) | func (m *mockHandler) HandleLLMGenerateContentEnd(ctx context.Context,...
method HandleLLMError (line 43) | func (m *mockHandler) HandleLLMError(ctx context.Context, err error) {
method HandleChainStart (line 47) | func (m *mockHandler) HandleChainStart(ctx context.Context, inputs map...
method HandleChainEnd (line 51) | func (m *mockHandler) HandleChainEnd(ctx context.Context, outputs map[...
method HandleChainError (line 55) | func (m *mockHandler) HandleChainError(ctx context.Context, err error) {
method HandleToolStart (line 59) | func (m *mockHandler) HandleToolStart(ctx context.Context, input strin...
method HandleToolEnd (line 63) | func (m *mockHandler) HandleToolEnd(ctx context.Context, output string) {
method HandleToolError (line 67) | func (m *mockHandler) HandleToolError(ctx context.Context, err error) {
method HandleAgentAction (line 71) | func (m *mockHandler) HandleAgentAction(ctx context.Context, action sc...
method HandleAgentFinish (line 75) | func (m *mockHandler) HandleAgentFinish(ctx context.Context, finish sc...
method HandleRetrieverStart (line 79) | func (m *mockHandler) HandleRetrieverStart(ctx context.Context, query ...
method HandleRetrieverEnd (line 83) | func (m *mockHandler) HandleRetrieverEnd(ctx context.Context, query st...
method HandleStreamingFunc (line 87) | func (m *mockHandler) HandleStreamingFunc(ctx context.Context, chunk [...
function TestSimpleHandler (line 91) | func TestSimpleHandler(t *testing.T) {
function TestCombiningHandler (line 121) | func TestCombiningHandler(t *testing.T) {
function TestCombiningHandlerStructure (line 218) | func TestCombiningHandlerStructure(t *testing.T) {
function TestHandlerInterfaceCompleteness (line 239) | func TestHandlerInterfaceCompleteness(t *testing.T) {
function TestHandlerHaverInterface (line 252) | func TestHandlerHaverInterface(t *testing.T) {
function TestComplexCombiningScenario (line 265) | func TestComplexCombiningScenario(t *testing.T) {
function TestCombiningHandlerWithMixedTypes (line 289) | func TestCombiningHandlerWithMixedTypes(t *testing.T) {
function TestCallbackTypes (line 310) | func TestCallbackTypes(t *testing.T) {
FILE: callbacks/combining.go
type CombiningHandler (line 11) | type CombiningHandler struct
method HandleText (line 17) | func (l CombiningHandler) HandleText(ctx context.Context, text string) {
method HandleLLMStart (line 23) | func (l CombiningHandler) HandleLLMStart(ctx context.Context, prompts ...
method HandleLLMGenerateContentStart (line 29) | func (l CombiningHandler) HandleLLMGenerateContentStart(ctx context.Co...
method HandleLLMGenerateContentEnd (line 35) | func (l CombiningHandler) HandleLLMGenerateContentEnd(ctx context.Cont...
method HandleChainStart (line 41) | func (l CombiningHandler) HandleChainStart(ctx context.Context, inputs...
method HandleChainEnd (line 47) | func (l CombiningHandler) HandleChainEnd(ctx context.Context, outputs ...
method HandleToolStart (line 53) | func (l CombiningHandler) HandleToolStart(ctx context.Context, input s...
method HandleToolEnd (line 59) | func (l CombiningHandler) HandleToolEnd(ctx context.Context, output st...
method HandleAgentAction (line 65) | func (l CombiningHandler) HandleAgentAction(ctx context.Context, actio...
method HandleAgentFinish (line 71) | func (l CombiningHandler) HandleAgentFinish(ctx context.Context, finis...
method HandleRetrieverStart (line 77) | func (l CombiningHandler) HandleRetrieverStart(ctx context.Context, qu...
method HandleRetrieverEnd (line 83) | func (l CombiningHandler) HandleRetrieverEnd(ctx context.Context, quer...
method HandleStreamingFunc (line 89) | func (l CombiningHandler) HandleStreamingFunc(ctx context.Context, chu...
method HandleChainError (line 95) | func (l CombiningHandler) HandleChainError(ctx context.Context, err er...
method HandleLLMError (line 101) | func (l CombiningHandler) HandleLLMError(ctx context.Context, err erro...
method HandleToolError (line 107) | func (l CombiningHandler) HandleToolError(ctx context.Context, err err...
FILE: callbacks/log.go
type LogHandler (line 14) | type LogHandler struct
method HandleLLMGenerateContentStart (line 18) | func (l LogHandler) HandleLLMGenerateContentStart(_ context.Context, m...
method HandleLLMGenerateContentEnd (line 33) | func (l LogHandler) HandleLLMGenerateContentEnd(_ context.Context, res...
method HandleStreamingFunc (line 54) | func (l LogHandler) HandleStreamingFunc(_ context.Context, chunk []byt...
method HandleText (line 58) | func (l LogHandler) HandleText(_ context.Context, text string) {
method HandleLLMStart (line 62) | func (l LogHandler) HandleLLMStart(_ context.Context, prompts []string) {
method HandleLLMError (line 66) | func (l LogHandler) HandleLLMError(_ context.Context, err error) {
method HandleChainStart (line 70) | func (l LogHandler) HandleChainStart(_ context.Context, inputs map[str...
method HandleChainEnd (line 74) | func (l LogHandler) HandleChainEnd(_ context.Context, outputs map[stri...
method HandleChainError (line 78) | func (l LogHandler) HandleChainError(_ context.Context, err error) {
method HandleToolStart (line 82) | func (l LogHandler) HandleToolStart(_ context.Context, input string) {
method HandleToolEnd (line 86) | func (l LogHandler) HandleToolEnd(_ context.Context, output string) {
method HandleToolError (line 90) | func (l LogHandler) HandleToolError(_ context.Context, err error) {
method HandleAgentAction (line 94) | func (l LogHandler) HandleAgentAction(_ context.Context, action schema...
method HandleAgentFinish (line 98) | func (l LogHandler) HandleAgentFinish(_ context.Context, finish schema...
method HandleRetrieverStart (line 102) | func (l LogHandler) HandleRetrieverStart(_ context.Context, query stri...
method HandleRetrieverEnd (line 106) | func (l LogHandler) HandleRetrieverEnd(_ context.Context, query string...
function formatChainValues (line 110) | func formatChainValues(values map[string]any) string {
function formatAgentAction (line 119) | func formatAgentAction(action schema.AgentAction) string {
function removeNewLines (line 123) | func removeNewLines(s any) string {
FILE: callbacks/log_stream.go
type StreamLogHandler (line 10) | type StreamLogHandler struct
method HandleStreamingFunc (line 16) | func (StreamLogHandler) HandleStreamingFunc(_ context.Context, chunk [...
FILE: callbacks/simple.go
type SimpleHandler (line 11) | type SimpleHandler struct
method HandleText (line 15) | func (SimpleHandler) HandleText(context.Context, string) ...
method HandleLLMStart (line 16) | func (SimpleHandler) HandleLLMStart(context.Context, []string) ...
method HandleLLMGenerateContentStart (line 17) | func (SimpleHandler) HandleLLMGenerateContentStart(context.Context, []...
method HandleLLMGenerateContentEnd (line 18) | func (SimpleHandler) HandleLLMGenerateContentEnd(context.Context, *llm...
method HandleLLMError (line 19) | func (SimpleHandler) HandleLLMError(context.Context, error) ...
method HandleChainStart (line 20) | func (SimpleHandler) HandleChainStart(context.Context, map[string]any)...
method HandleChainEnd (line 21) | func (SimpleHandler) HandleChainEnd(context.Context, map[string]any) ...
method HandleChainError (line 22) | func (SimpleHandler) HandleChainError(context.Context, error) ...
method HandleToolStart (line 23) | func (SimpleHandler) HandleToolStart(context.Context, string) ...
method HandleToolEnd (line 24) | func (SimpleHandler) HandleToolEnd(context.Context, string) ...
method HandleToolError (line 25) | func (SimpleHandler) HandleToolError(context.Context, error) ...
method HandleAgentAction (line 26) | func (SimpleHandler) HandleAgentAction(context.Context, schema.AgentAc...
method HandleAgentFinish (line 27) | func (SimpleHandler) HandleAgentFinish(context.Context, schema.AgentFi...
method HandleRetrieverStart (line 28) | func (SimpleHandler) HandleRetrieverStart(context.Context, string) ...
method HandleRetrieverEnd (line 29) | func (SimpleHandler) HandleRetrieverEnd(context.Context, string, []sch...
method HandleStreamingFunc (line 30) | func (SimpleHandler) HandleStreamingFunc(context.Context, []byte) ...
FILE: chains/api.go
type HTTPRequest (line 28) | type HTTPRequest interface
type APIChain (line 32) | type APIChain struct
method Call (line 60) | func (a APIChain) Call(ctx context.Context, values map[string]any, opt...
method GetMemory (line 112) | func (a APIChain) GetMemory() schema.Memory { //nolint:ireturn
method GetInputKeys (line 120) | func (a APIChain) GetInputKeys() []string {
method GetOutputKeys (line 128) | func (a APIChain) GetOutputKeys() []string {
method runRequest (line 132) | func (a APIChain) runRequest(
function NewAPIChain (line 42) | func NewAPIChain(llm llms.Model, request HTTPRequest) APIChain {
FILE: chains/api_test.go
constant MeteoDocs (line 14) | MeteoDocs = `BASE URL: https://api.open-meteo.com/
function TestAPI (line 47) | func TestAPI(t *testing.T) {
FILE: chains/chains.go
constant _intermediateStepsOutputKey (line 13) | _intermediateStepsOutputKey = "intermediateSteps"
type Chain (line 16) | type Chain interface
function Call (line 30) | func Call(ctx context.Context, c Chain, inputValues map[string]any, opti...
function callChain (line 69) | func callChain(
function Run (line 92) | func Run(ctx context.Context, c Chain, input any, options ...ChainCallOp...
function Predict (line 135) | func Predict(ctx context.Context, c Chain, inputValues map[string]any, o...
constant _defaultApplyMaxNumberWorkers (line 154) | _defaultApplyMaxNumberWorkers = 5
type applyInputJob (line 156) | type applyInputJob struct
type applyResult (line 161) | type applyResult struct
function Apply (line 168) | func Apply(ctx context.Context, c Chain, inputValues []map[string]any, m...
function sendApplyInputJobs (line 210) | func sendApplyInputJobs(inputJobs chan applyInputJob, inputValues []map[...
function getApplyResults (line 220) | func getApplyResults(ctx context.Context, resultsChan chan applyResult, ...
function validateInputs (line 237) | func validateInputs(c Chain, inputValues map[string]any) error {
function validateOutputs (line 246) | func validateOutputs(c Chain, outputValues map[string]any) error {
function getChainCallbackHandler (line 255) | func getChainCallbackHandler(c Chain) callbacks.Handler {
FILE: chains/chains_test.go
type testLanguageModel (line 16) | type testLanguageModel struct
method Call (line 38) | func (l *testLanguageModel) Call(ctx context.Context, prompt string, o...
method GenerateContent (line 42) | func (l *testLanguageModel) GenerateContent(_ context.Context, mc []ll...
type stringPromptValue (line 26) | type stringPromptValue struct
method String (line 30) | func (spv stringPromptValue) String() string {
method Messages (line 34) | func (spv stringPromptValue) Messages() []llms.ChatMessage {
function TestApply (line 77) | func TestApply(t *testing.T) {
function TestApplyWithCanceledContext (line 96) | func TestApplyWithCanceledContext(t *testing.T) {
FILE: chains/chains_unit_test.go
type mockChain (line 17) | type mockChain struct
method Call (line 24) | func (m *mockChain) Call(ctx context.Context, inputs map[string]any, o...
method GetMemory (line 32) | func (m *mockChain) GetMemory() schema.Memory {
method GetInputKeys (line 39) | func (m *mockChain) GetInputKeys() []string {
method GetOutputKeys (line 43) | func (m *mockChain) GetOutputKeys() []string {
type mockMemory (line 47) | type mockMemory struct
method MemoryVariables (line 51) | func (m *mockMemory) MemoryVariables(ctx context.Context) []string {
method LoadMemoryVariables (line 56) | func (m *mockMemory) LoadMemoryVariables(ctx context.Context, inputs m...
method SaveContext (line 64) | func (m *mockMemory) SaveContext(ctx context.Context, inputs, outputs ...
method Clear (line 69) | func (m *mockMemory) Clear(ctx context.Context) error {
method GetMemoryKey (line 74) | func (m *mockMemory) GetMemoryKey(ctx context.Context) string {
function TestValidateInputs (line 79) | func TestValidateInputs(t *testing.T) {
function TestValidateOutputs (line 133) | func TestValidateOutputs(t *testing.T) {
function TestGetChainCallbackHandler (line 180) | func TestGetChainCallbackHandler(t *testing.T) {
type mockHandlerHaver (line 200) | type mockHandlerHaver struct
method GetCallbackHandler (line 204) | func (m *mockHandlerHaver) GetCallbackHandler() callbacks.Handler {
method Call (line 208) | func (m *mockHandlerHaver) Call(ctx context.Context, inputs map[string...
method GetMemory (line 212) | func (m *mockHandlerHaver) GetMemory() schema.Memory {
method GetInputKeys (line 216) | func (m *mockHandlerHaver) GetInputKeys() []string {
method GetOutputKeys (line 220) | func (m *mockHandlerHaver) GetOutputKeys() []string {
function TestSendApplyInputJobs (line 224) | func TestSendApplyInputJobs(t *testing.T) {
function TestConstants (line 253) | func TestConstants(t *testing.T) {
function TestErrorConstants (line 260) | func TestErrorConstants(t *testing.T) {
function TestChainInterface (line 337) | func TestChainInterface(t *testing.T) {
function TestRunErrors (line 344) | func TestRunErrors(t *testing.T) {
function TestPredictErrors (line 405) | func TestPredictErrors(t *testing.T) {
function TestCallChainWithValidationErrors (line 456) | func TestCallChainWithValidationErrors(t *testing.T) {
function TestApplyStructs (line 514) | func TestApplyStructs(t *testing.T) {
function TestApplyWithZeroMaxWorkers (line 538) | func TestApplyWithZeroMaxWorkers(t *testing.T) {
function TestRunWithMemoryKeys (line 567) | func TestRunWithMemoryKeys(t *testing.T) {
FILE: chains/constitution/constitutional.go
type pair (line 22) | type pair struct
type ConstitutionalPrinciple (line 27) | type ConstitutionalPrinciple struct
type Constitutional (line 35) | type Constitutional struct
method Call (line 96) | func (c *Constitutional) Call(ctx context.Context, inputs map[string]any,
method processCritiquesAndRevisions (line 128) | func (c *Constitutional) processCritiquesAndRevisions(ctx context.Cont...
method GetMemory (line 199) | func (c *Constitutional) GetMemory() schema.Memory {
method GetInputKeys (line 203) | func (c *Constitutional) GetInputKeys() []string {
method GetOutputKeys (line 207) | func (c *Constitutional) GetOutputKeys() []string {
function NewConstitutionalPrinciple (line 46) | func NewConstitutionalPrinciple(critique, revision string, names ...stri...
function NewConstitutional (line 61) | func NewConstitutional(llm llms.Model, chain chains.LLMChain,
function parseCritique (line 188) | func parseCritique(rawCritique string) string {
FILE: chains/constitution/constitutional_test.go
function hasExistingRecording (line 20) | func hasExistingRecording(t *testing.T) bool {
function TestConstitutionCritiqueParsing (line 28) | func TestConstitutionCritiqueParsing(t *testing.T) {
function TestConstitutionalChain (line 51) | func TestConstitutionalChain(t *testing.T) {
FILE: chains/constitution/prompts.go
type constitutionalExample (line 5) | type constitutionalExample struct
function getConstitutionalExample (line 16) | func getConstitutionalExample() []constitutionalExample {
function initCritiqueRevision (line 104) | func initCritiqueRevision() (*prompts.FewShotPrompt, *prompts.FewShotPro...
FILE: chains/constitutional.go
type ConstitutionalPrinciple (line 354) | type ConstitutionalPrinciple struct
type Pair (line 360) | type Pair struct
type ConstitutionalExample (line 364) | type ConstitutionalExample struct
type Constitutional (line 373) | type Constitutional struct
method Call (line 595) | func (c *Constitutional) Call(ctx context.Context, inputs map[string]a...
method processCritiquesAndRevisions (line 627) | func (c *Constitutional) processCritiquesAndRevisions(ctx context.Cont...
method GetMemory (line 702) | func (c *Constitutional) GetMemory() schema.Memory {
method GetInputKeys (line 706) | func (c *Constitutional) GetInputKeys() []string {
method GetOutputKeys (line 710) | func (c *Constitutional) GetOutputKeys() []string {
function getConstitutionalExample (line 385) | func getConstitutionalExample() []ConstitutionalExample {
function initCritiqueRevision (line 473) | func initCritiqueRevision() (*prompts.FewShotPrompt, *prompts.FewShotPro...
function NewConstitutionalPrinciple (line 545) | func NewConstitutionalPrinciple(critique, revision string, names ...stri...
function NewConstitutional (line 560) | func NewConstitutional(llm llms.Model, chain LLMChain, constitutionalPri...
function parseCritique (line 691) | func parseCritique(rawCritique string) string {
FILE: chains/constitutional_test.go
function TestConstitutionCritiqueParsing (line 16) | func TestConstitutionCritiqueParsing(t *testing.T) {
function TestConstitutionalChainBasic (line 39) | func TestConstitutionalChainBasic(t *testing.T) {
FILE: chains/conversation.go
constant _conversationTemplate (line 11) | _conversationTemplate = `The following is a friendly conversation betwee...
function NewConversation (line 18) | func NewConversation(llm llms.Model, memory schema.Memory) LLMChain {
FILE: chains/conversation_test.go
function TestConversation (line 20) | func TestConversation(t *testing.T) {
function TestConversationWithZepMemory (line 54) | func TestConversationWithZepMemory(t *testing.T) {
function TestConversationWithChatLLM (line 102) | func TestConversationWithChatLLM(t *testing.T) {
FILE: chains/conversational_retrieval_qa.go
constant _conversationalRetrievalQADefaultInputKey (line 12) | _conversationalRetrievalQADefaultInputKey = "question"
constant _conversationalRetrievalQADefaultSourceDocumentKey (line 13) | _conversationalRetrievalQADefaultSourceDocumentKey = "source_documents"
constant _conversationalRetrievalQADefaultGeneratedQuestionKey (line 14) | _conversationalRetrievalQADefaultGeneratedQuestionKey = "generated_quest...
type ConversationalRetrievalQA (line 18) | type ConversationalRetrievalQA struct
method Call (line 91) | func (c ConversationalRetrievalQA) Call(ctx context.Context, values ma...
method GetMemory (line 142) | func (c ConversationalRetrievalQA) GetMemory() schema.Memory {
method GetInputKeys (line 146) | func (c ConversationalRetrievalQA) GetInputKeys() []string {
method GetOutputKeys (line 150) | func (c ConversationalRetrievalQA) GetOutputKeys() []string {
method getQuestion (line 159) | func (c ConversationalRetrievalQA) getQuestion(
method rephraseQuestion (line 188) | func (c ConversationalRetrievalQA) rephraseQuestion(question string, n...
function NewConversationalRetrievalQA (line 57) | func NewConversationalRetrievalQA(
function NewConversationalRetrievalQAFromLLM (line 76) | func NewConversationalRetrievalQAFromLLM(
FILE: chains/conversational_retrieval_qa_test.go
type testConversationalRetriever (line 16) | type testConversationalRetriever struct
method GetRelevantDocuments (line 18) | func (t testConversationalRetriever) GetRelevantDocuments(_ context.Co...
function createOpenAILLMForConversationalRetrievalQA (line 62) | func createOpenAILLMForConversationalRetrievalQA(t *testing.T) *openai.L...
function TestConversationalRetrievalQA (line 78) | func TestConversationalRetrievalQA(t *testing.T) {
function TestConversationalRetrievalQAWithReturnMessages (line 105) | func TestConversationalRetrievalQAWithReturnMessages(t *testing.T) {
function TestConversationalRetrievalQAFromLLM (line 132) | func TestConversationalRetrievalQAFromLLM(t *testing.T) {
function TestConversationalRetrievalQAFromLLMWithConversationTokenBuffer (line 151) | func TestConversationalRetrievalQAFromLLMWithConversationTokenBuffer(t *...
FILE: chains/llm.go
constant _llmChainDefaultOutputKey (line 14) | _llmChainDefaultOutputKey = "text"
type LLMChain (line 16) | type LLMChain struct
method Call (line 53) | func (c LLMChain) Call(ctx context.Context, values map[string]any, opt...
method GetMemory (line 73) | func (c LLMChain) GetMemory() schema.Memory { //nolint:ireturn
method GetCallbackHandler (line 77) | func (c LLMChain) GetCallbackHandler() callbacks.Handler { //nolint:ir...
method GetInputKeys (line 82) | func (c LLMChain) GetInputKeys() []string {
method GetOutputKeys (line 87) | func (c LLMChain) GetOutputKeys() []string {
function NewLLMChain (line 32) | func NewLLMChain(llm llms.Model, prompt prompts.FormatPrompter, opts ......
FILE: chains/llm_azure_test.go
function TestLLMChainAzure (line 16) | func TestLLMChainAzure(t *testing.T) {
FILE: chains/llm_math.go
type LLMMathChain (line 22) | type LLMMathChain struct
method Call (line 37) | func (c LLMMathChain) Call(ctx context.Context, values map[string]any,...
method GetMemory (line 52) | func (c LLMMathChain) GetMemory() schema.Memory { //nolint:ireturn
method GetInputKeys (line 56) | func (c LLMMathChain) GetInputKeys() []string {
method GetOutputKeys (line 60) | func (c LLMMathChain) GetOutputKeys() []string {
method processLLMResult (line 66) | func (c LLMMathChain) processLLMResult(llmOutput string) (string, erro...
method evaluateExpression (line 83) | func (c LLMMathChain) evaluateExpression(expression string) (string, e...
function NewLLMMathChain (line 28) | func NewLLMMathChain(llm llms.Model) LLMMathChain {
FILE: chains/llm_math_test.go
function TestLLMMath (line 14) | func TestLLMMath(t *testing.T) {
FILE: chains/llm_test.go
function hasExistingRecording (line 21) | func hasExistingRecording(t *testing.T) bool {
function TestLLMChain (line 29) | func TestLLMChain(t *testing.T) {
function TestLLMChainWithChatPromptTemplate (line 68) | func TestLLMChainWithChatPromptTemplate(t *testing.T) {
function TestLLMChainWithGoogleAI (line 87) | func TestLLMChainWithGoogleAI(t *testing.T) {
FILE: chains/map_reduce.go
type MapReduceDocuments (line 14) | type MapReduceDocuments struct
method Call (line 59) | func (c MapReduceDocuments) Call(ctx context.Context, values map[strin...
method getInputVariable (line 84) | func (c MapReduceDocuments) getInputVariable(givenInputName string, ch...
method maybeAddIntermediateSteps (line 92) | func (c MapReduceDocuments) maybeAddIntermediateSteps(result map[strin...
method getApplyInputs (line 101) | func (c MapReduceDocuments) getApplyInputs(values map[string]any, docs...
method mapResultsToReduceInputs (line 113) | func (c MapReduceDocuments) mapResultsToReduceInputs(
method copyInputValuesWithoutInputKey (line 138) | func (c MapReduceDocuments) copyInputValuesWithoutInputKey(inputValues...
method GetInputKeys (line 145) | func (c MapReduceDocuments) GetInputKeys() []string {
method GetOutputKeys (line 168) | func (c MapReduceDocuments) GetOutputKeys() []string {
method GetMemory (line 177) | func (c MapReduceDocuments) GetMemory() schema.Memory { //nolint:ireturn
function NewMapReduceDocuments (line 46) | func NewMapReduceDocuments(llmChain *LLMChain, reduceChain Chain) MapRed...
FILE: chains/map_reduce_test.go
function TestMapReduceInputVariables (line 12) | func TestMapReduceInputVariables(t *testing.T) {
function TestMapReduce (line 34) | func TestMapReduce(t *testing.T) {
FILE: chains/map_rerank_documents.go
constant _mapRerankDocumentsDefaultDocumentTemplate (line 16) | _mapRerankDocumentsDefaultDocumentTemplate = "{{.page_content}}"
constant _mapRerankDocumentsDefaultRankKey (line 17) | _mapRerankDocumentsDefaultRankKey = "score"
constant _mapRerankDocumentsDefaultAnswerKey (line 18) | _mapRerankDocumentsDefaultAnswerKey = "answer"
type MapRerankDocuments (line 21) | type MapRerankDocuments struct
method Call (line 70) | func (c MapRerankDocuments) Call(ctx context.Context, values map[strin...
method getInputVariable (line 118) | func (c MapRerankDocuments) getInputVariable(givenInputName string, ch...
method getApplyInputs (line 127) | func (c MapRerankDocuments) getApplyInputs(values map[string]any, docs...
method copyInputValuesWithoutInputKey (line 140) | func (c MapRerankDocuments) copyInputValuesWithoutInputKey(inputValues...
method parseMapResults (line 148) | func (c MapRerankDocuments) parseMapResults(inputs map[string]string) ...
method formatOutputs (line 159) | func (c MapRerankDocuments) formatOutputs(outputs []map[string]any) ma...
method GetInputKeys (line 179) | func (c MapRerankDocuments) GetInputKeys() []string {
method GetOutputKeys (line 192) | func (c MapRerankDocuments) GetOutputKeys() []string {
method GetMemory (line 203) | func (c MapRerankDocuments) GetMemory() schema.Memory { //nolint:ireturn
function NewMapRerankDocuments (line 53) | func NewMapRerankDocuments(mapRerankLLMChain *LLMChain) *MapRerankDocume...
FILE: chains/map_rerank_documents_test.go
function TestMapRerankInputVariables (line 12) | func TestMapRerankInputVariables(t *testing.T) {
function TestMapRerankDocumentsCall (line 32) | func TestMapRerankDocumentsCall(t *testing.T) {
FILE: chains/options.go
type ChainCallOption (line 11) | type ChainCallOption
type chainCallOption (line 21) | type chainCallOption struct
function WithModel (line 71) | func WithModel(model string) ChainCallOption {
function WithMaxTokens (line 79) | func WithMaxTokens(maxTokens int) ChainCallOption {
function WithTemperature (line 87) | func WithTemperature(temperature float64) ChainCallOption {
function WithStreamingFunc (line 95) | func WithStreamingFunc(streamingFunc func(ctx context.Context, chunk []b...
function WithTopK (line 102) | func WithTopK(topK int) ChainCallOption {
function WithTopP (line 110) | func WithTopP(topP float64) ChainCallOption {
function WithSeed (line 118) | func WithSeed(seed int) ChainCallOption {
function WithMinLength (line 126) | func WithMinLength(minLength int) ChainCallOption {
function WithMaxLength (line 134) | func WithMaxLength(maxLength int) ChainCallOption {
function WithRepetitionPenalty (line 142) | func WithRepetitionPenalty(repetitionPenalty float64) ChainCallOption {
function WithStopWords (line 150) | func WithStopWords(stopWords []string) ChainCallOption {
function WithCallback (line 158) | func WithCallback(callbackHandler callbacks.Handler) ChainCallOption {
function GetLLMCallOptions (line 167) | func GetLLMCallOptions(options ...ChainCallOption) []llms.CallOption { /...
function getLLMCallOptions (line 217) | func getLLMCallOptions(options ...ChainCallOption) []llms.CallOption {
FILE: chains/prompt_selector.go
type PromptSelector (line 10) | type PromptSelector interface
type ConditionalPromptSelector (line 16) | type ConditionalPromptSelector struct
method GetPrompt (line 26) | func (s ConditionalPromptSelector) GetPrompt(llm llms.Model) prompts.P...
FILE: chains/question_answering.go
constant _defaultStuffQATemplate (line 9) | _defaultStuffQATemplate = `Use the following pieces of context to answer...
constant _defaultRefineQATemplate (line 16) | _defaultRefineQATemplate = `The original question is as follows: {{.ques...
constant _defaultMapReduceGetInformationQATemplate (line 27) | _defaultMapReduceGetInformationQATemplate = `Use the following portion o...
constant _defaultMapReduceCombineQATemplate (line 34) | _defaultMapReduceCombineQATemplate = `Given the following extracted part...
constant _defaultMapRerankTemplate (line 44) | _defaultMapRerankTemplate = `Use the following pieces of context to answ...
constant _defaultCondenseQuestionTemplate (line 87) | _defaultCondenseQuestionTemplate = `Given the following conversation and...
function LoadCondenseQuestionGenerator (line 95) | func LoadCondenseQuestionGenerator(llm llms.Model) *LLMChain {
function LoadStuffQA (line 104) | func LoadStuffQA(llm llms.Model) StuffDocuments {
function LoadRefineQA (line 121) | func LoadRefineQA(llm llms.Model) RefineDocuments {
function LoadMapReduceQA (line 139) | func LoadMapReduceQA(llm llms.Model) MapReduceDocuments {
function LoadMapRerankQA (line 159) | func LoadMapRerankQA(llm llms.Model) MapRerankDocuments {
FILE: chains/question_answering_test.go
function createOpenAILLMForQA (line 15) | func createOpenAILLMForQA(t *testing.T) *openai.LLM {
function TestRefineQA (line 41) | func TestRefineQA(t *testing.T) {
function TestMapReduceQA (line 63) | func TestMapReduceQA(t *testing.T) {
function TestMapRerankQA (line 84) | func TestMapRerankQA(t *testing.T) {
FILE: chains/refine_documents.go
constant _refineDocumentsDefaultDocumentTemplate (line 13) | _refineDocumentsDefaultDocumentTemplate = "{{.page_content}}"
constant _refineDocumentsDefaultInitialResponseName (line 14) | _refineDocumentsDefaultInitialResponseName = "existing_answer"
type RefineDocuments (line 21) | type RefineDocuments struct
method Call (line 60) | func (c RefineDocuments) Call(ctx context.Context, values map[string]a...
method constructInitialInputs (line 106) | func (c RefineDocuments) constructInitialInputs(doc schema.Document, r...
method constructRefineInputs (line 110) | func (c RefineDocuments) constructRefineInputs(doc schema.Document, la...
method getBaseInputs (line 122) | func (c RefineDocuments) getBaseInputs(doc schema.Document, rest map[s...
method GetInputKeys (line 153) | func (c RefineDocuments) GetInputKeys() []string {
method GetOutputKeys (line 165) | func (c RefineDocuments) GetOutputKeys() []string {
method GetMemory (line 169) | func (c RefineDocuments) GetMemory() schema.Memory { //nolint:ireturn
function NewRefineDocuments (line 44) | func NewRefineDocuments(initialLLMChain, refineLLMChain *LLMChain) Refin...
FILE: chains/retrieval_qa.go
constant _retrievalQADefaultInputKey (line 13) | _retrievalQADefaultInputKey = "query"
constant _retrievalQADefaultSourceDocumentKey (line 14) | _retrievalQADefaultSourceDocumentKey = "source_documents"
type RetrievalQA (line 21) | type RetrievalQA struct
method Call (line 62) | func (c RetrievalQA) Call(ctx context.Context, values map[string]any, ...
method GetMemory (line 88) | func (c RetrievalQA) GetMemory() schema.Memory { //nolint:ireturn
method GetInputKeys (line 92) | func (c RetrievalQA) GetInputKeys() []string {
method GetOutputKeys (line 96) | func (c RetrievalQA) GetOutputKeys() []string {
function NewRetrievalQA (line 42) | func NewRetrievalQA(combineDocumentsChain Chain, retriever schema.Retrie...
function NewRetrievalQAFromLLM (line 53) | func NewRetrievalQAFromLLM(llm llms.Model, retriever schema.Retriever) R...
FILE: chains/retrieval_qa_test.go
type testRetriever (line 16) | type testRetriever struct
method GetRelevantDocuments (line 20) | func (r testRetriever) GetRelevantDocuments(_ context.Context, _ strin...
function createOpenAILLMForRetrieval (line 28) | func createOpenAILLMForRetrieval(t *testing.T) *openai.LLM {
function TestRetrievalQA (line 54) | func TestRetrievalQA(t *testing.T) {
function TestRetrievalQAFromLLM (line 74) | func TestRetrievalQAFromLLM(t *testing.T) {
FILE: chains/sequential.go
constant delimiter (line 15) | delimiter = ","
type SequentialChain (line 19) | type SequentialChain struct
method validateSeqChain (line 45) | func (c *SequentialChain) validateSeqChain() error {
method Call (line 101) | func (c *SequentialChain) Call(ctx context.Context, inputs map[string]...
method GetMemory (line 116) | func (c *SequentialChain) GetMemory() schema.Memory {
method GetInputKeys (line 121) | func (c *SequentialChain) GetInputKeys() []string {
method GetOutputKeys (line 126) | func (c *SequentialChain) GetOutputKeys() []string {
function NewSequentialChain (line 26) | func NewSequentialChain(chains []Chain, inputKeys []string, outputKeys [...
constant input (line 131) | input = "input"
constant output (line 132) | output = "output"
type SimpleSequentialChain (line 143) | type SimpleSequentialChain struct
method Call (line 178) | func (c *SimpleSequentialChain) Call(ctx context.Context, inputs map[s...
method GetMemory (line 191) | func (c *SimpleSequentialChain) GetMemory() schema.Memory {
method GetInputKeys (line 196) | func (c *SimpleSequentialChain) GetInputKeys() []string {
method GetOutputKeys (line 201) | func (c *SimpleSequentialChain) GetOutputKeys() []string {
function NewSimpleSequentialChain (line 148) | func NewSimpleSequentialChain(chains []Chain) (*SimpleSequentialChain, e...
function validateSimpleSeq (line 156) | func validateSimpleSeq(chains []Chain) error {
type SequentialChainOption (line 205) | type SequentialChainOption
function WithSeqChainMemory (line 207) | func WithSeqChainMemory(memory schema.Memory) SequentialChainOption {
FILE: chains/sequential_test.go
function TestSimpleSequential (line 17) | func TestSimpleSequential(t *testing.T) {
function TestSimpleSequentialErrors (line 43) | func TestSimpleSequentialErrors(t *testing.T) {
function TestSequentialChain (line 85) | func TestSequentialChain(t *testing.T) {
function TestSequentialChainErrors (line 126) | func TestSequentialChainErrors(t *testing.T) {
type testLLMChain (line 200) | type testLLMChain struct
method Call (line 209) | func (c *testLLMChain) Call(_ context.Context, _ map[string]any, _ ......
method GetMemory (line 214) | func (c *testLLMChain) GetMemory() schema.Memory {
method GetInputKeys (line 219) | func (c *testLLMChain) GetInputKeys() []string {
method GetOutputKeys (line 224) | func (c *testLLMChain) GetOutputKeys() []string {
FILE: chains/sql_database.go
constant _defaultSQLTemplate (line 16) | _defaultSQLTemplate = `Given an input question, first create a syntactic...
constant _defaultSQLSuffix (line 32) | _defaultSQLSuffix = `Only use the following tables:
constant _sqlChainDefaultInputKeyQuery (line 38) | _sqlChainDefaultInputKeyQuery = "query"
constant _sqlChainDefaultInputKeyTableNames (line 39) | _sqlChainDefaultInputKeyTableNames = "table_names_to_use"
constant _sqlChainDefaultOutputKey (line 40) | _sqlChainDefaultOutputKey = "result"
type SQLDatabaseChain (line 44) | type SQLDatabaseChain struct
method Call (line 77) | func (s SQLDatabaseChain) Call(ctx context.Context, inputs map[string]...
method GetMemory (line 145) | func (s SQLDatabaseChain) GetMemory() schema.Memory { //nolint:ireturn
method GetInputKeys (line 149) | func (s SQLDatabaseChain) GetInputKeys() []string {
method GetOutputKeys (line 153) | func (s SQLDatabaseChain) GetOutputKeys() []string {
function NewSQLDatabaseChain (line 53) | func NewSQLDatabaseChain(llm llms.Model, topK int, database *sqldatabase...
function extractSQLQuery (line 162) | func extractSQLQuery(rawOut string) string {
FILE: chains/sql_database_test.go
function TestSQLDatabaseChain_Call (line 16) | func TestSQLDatabaseChain_Call(t *testing.T) {
function TestExtractSQLQuery (line 66) | func TestExtractSQLQuery(t *testing.T) {
FILE: chains/stuff_documents.go
constant _combineDocumentsDefaultInputKey (line 12) | _combineDocumentsDefaultInputKey = "input_documents"
constant _combineDocumentsDefaultOutputKey (line 13) | _combineDocumentsDefaultOutputKey = "text"
constant _combineDocumentsDefaultDocumentVariableName (line 14) | _combineDocumentsDefaultDocumentVariableName = "context"
constant _stuffDocumentsDefaultSeparator (line 15) | _stuffDocumentsDefaultSeparator = "\n\n"
type StuffDocuments (line 23) | type StuffDocuments struct
method Call (line 54) | func (c StuffDocuments) Call(
method GetMemory (line 72) | func (c StuffDocuments) GetMemory() schema.Memory {
method GetInputKeys (line 77) | func (c StuffDocuments) GetInputKeys() []string {
method GetOutputKeys (line 82) | func (c StuffDocuments) GetOutputKeys() []string {
method joinDocuments (line 87) | func (c StuffDocuments) joinDocuments(docs []schema.Document) string {
function NewStuffDocuments (line 43) | func NewStuffDocuments(llmChain *LLMChain) StuffDocuments {
FILE: chains/stuff_documents_test.go
function TestStuffDocuments (line 15) | func TestStuffDocuments(t *testing.T) {
function TestStuffDocuments_joinDocs (line 65) | func TestStuffDocuments_joinDocs(t *testing.T) {
FILE: chains/summarization.go
constant _stuffSummarizationTemplate (line 8) | _stuffSummarizationTemplate = `Write a concise summary of the following:
constant _refineSummarizationTemplate (line 16) | _refineSummarizationTemplate = `Your job is to produce a final concise s...
function LoadStuffSummarization (line 31) | func LoadStuffSummarization(llm llms.Model) StuffDocuments {
function LoadRefineSummarization (line 41) | func LoadRefineSummarization(llm llms.Model) RefineDocuments {
function LoadMapReduceSummarization (line 54) | func LoadMapReduceSummarization(llm llms.Model) MapReduceDocuments {
FILE: chains/summarization_test.go
function loadTestData (line 17) | func loadTestData(t *testing.T) []schema.Document {
function createOpenAILLMForTest (line 34) | func createOpenAILLMForTest(t *testing.T) *openai.LLM {
function TestStuffSummarization (line 60) | func TestStuffSummarization(t *testing.T) {
function TestRefineSummarization (line 76) | func TestRefineSummarization(t *testing.T) {
function TestMapReduceSummarization (line 92) | func TestMapReduceSummarization(t *testing.T) {
FILE: chains/transform.go
type TransformFunc (line 11) | type TransformFunc
type Transform (line 14) | type Transform struct
method Call (line 35) | func (c Transform) Call(ctx context.Context, inputs map[string]any, op...
method GetMemory (line 40) | func (c Transform) GetMemory() schema.Memory {
method GetInputKeys (line 45) | func (c Transform) GetInputKeys() []string {
method GetOutputKeys (line 50) | func (c Transform) GetOutputKeys() []string {
function NewTransform (line 25) | func NewTransform(f TransformFunc, inputVariables []string, outputVariab...
FILE: chains/transform_test.go
function TestTransform (line 11) | func TestTransform(t *testing.T) {
FILE: docs/.eslintrc.js
constant OFF (line 10) | const OFF = 0;
constant WARNING (line 11) | const WARNING = 1;
constant ERROR (line 12) | const ERROR = 2;
FILE: docs/code-block-loader.js
function webpackLoader (line 14) | async function webpackLoader(content, map, meta) {
FILE: docs/docusaurus.config.js
method sidebarItemsGenerator (line 75) | async sidebarItemsGenerator({
FILE: docs/search-indexer.go
type SearchEntry (line 27) | type SearchEntry struct
type SearchIndex (line 40) | type SearchIndex struct
type IndexMeta (line 46) | type IndexMeta struct
type Config (line 54) | type Config struct
function main (line 72) | func main() {
function parseFlags (line 102) | func parseFlags() Config {
type Indexer (line 118) | type Indexer struct
method ParseDocs (line 133) | func (idx *Indexer) ParseDocs() error {
method parseMarkdownFile (line 180) | func (idx *Indexer) parseMarkdownFile(md goldmark.Markdown, filePath s...
method generateDocURL (line 218) | func (idx *Indexer) generateDocURL(relPath string) string {
method extractTitle (line 236) | func (idx *Indexer) extractTitle(metaData map[string]interface{}, relP...
method cleanMarkdownContent (line 271) | func (idx *Indexer) cleanMarkdownContent(content string) string {
method extractKeywords (line 302) | func (idx *Indexer) extractKeywords(content string) []string {
method ParseGoSource (line 346) | func (idx *Indexer) ParseGoSource() error {
method parseGoFile (line 427) | func (idx *Indexer) parseGoFile(fileSet *token.FileSet, filePath strin...
method createFunctionEntry (line 494) | func (idx *Indexer) createFunctionEntry(fn *doc.Func, packagePath, pac...
method createTypeEntry (line 513) | func (idx *Indexer) createTypeEntry(typ *doc.Type, packagePath, packag...
method createMethodEntry (line 532) | func (idx *Indexer) createMethodEntry(method *doc.Func, typeName, pack...
method WriteIndex (line 551) | func (idx *Indexer) WriteIndex() error {
function NewIndexer (line 125) | func NewIndexer(config Config) *Indexer {
function copyFile (line 622) | func copyFile(src, dst string) error {
function convertMetadata (line 639) | func convertMetadata(metaData map[string]interface{}) map[string]string {
function formatFuncSignature (line 649) | func formatFuncSignature(fn *doc.Func) string {
function formatTypeSignature (line 659) | func formatTypeSignature(typ *doc.Type) string {
function isCommonWord (line 668) | func isCommonWord(word string) bool {
FILE: docs/src/pages/index.js
function Home (line 13) | function Home() {
FILE: docs/src/theme/CodeBlock/index.js
function CodeBlockWrapper (line 5) | function CodeBlockWrapper({ children, ...props }) {
FILE: docs/src/theme/SearchBar/index.js
function SearchBar (line 6) | function SearchBar() {
FILE: documentloaders/assemblyai.go
type TranscriptFormat (line 19) | type TranscriptFormat
constant TranscriptFormatText (line 23) | TranscriptFormatText TranscriptFormat = iota
constant TranscriptFormatSentences (line 26) | TranscriptFormatSentences
constant TranscriptFormatParagraphs (line 29) | TranscriptFormatParagraphs
constant TranscriptFormatSubtitlesSRT (line 32) | TranscriptFormatSubtitlesSRT
constant TranscriptFormatSubtitlesVTT (line 35) | TranscriptFormatSubtitlesVTT
type AssemblyAIAudioTranscriptLoader (line 46) | type AssemblyAIAudioTranscriptLoader struct
method Load (line 113) | func (a *AssemblyAIAudioTranscriptLoader) Load(ctx context.Context) ([...
method transcribe (line 129) | func (a *AssemblyAIAudioTranscriptLoader) transcribe(ctx context.Conte...
method formatTranscript (line 143) | func (a *AssemblyAIAudioTranscriptLoader) formatTranscript(ctx context...
method LoadAndSplit (line 241) | func (a *AssemblyAIAudioTranscriptLoader) LoadAndSplit(ctx context.Con...
type AssemblyAIOption (line 65) | type AssemblyAIOption
function NewAssemblyAIAudioTranscript (line 69) | func NewAssemblyAIAudioTranscript(apiKey string, opts ...AssemblyAIOptio...
function WithAudioURL (line 84) | func WithAudioURL(url string) AssemblyAIOption {
function WithAudioReader (line 91) | func WithAudioReader(r io.Reader) AssemblyAIOption {
function WithTranscriptFormat (line 98) | func WithTranscriptFormat(format TranscriptFormat) AssemblyAIOption {
function WithTranscriptParams (line 105) | func WithTranscriptParams(params *assemblyai.TranscriptOptionalParams) A...
function documentsFromSentences (line 185) | func documentsFromSentences(sentences []assemblyai.TranscriptSentence) (...
function documentsFromParagraphs (line 203) | func documentsFromParagraphs(paragraphs []assemblyai.TranscriptParagraph...
function toMetadata (line 222) | func toMetadata(obj any) (map[string]any, error) {
FILE: documentloaders/assemblyai_test.go
function TestAssemblyAIAudioTranscriptLoader_Load (line 12) | func TestAssemblyAIAudioTranscriptLoader_Load(t *testing.T) {
function TestAssemblyAIAudioTranscriptLoader_toMetadata (line 47) | func TestAssemblyAIAudioTranscriptLoader_toMetadata(t *testing.T) {
FILE: documentloaders/csv.go
type CSV (line 17) | type CSV struct
method Load (line 33) | func (c CSV) Load(_ context.Context) ([]schema.Document, error) {
method LoadAndSplit (line 75) | func (c CSV) LoadAndSplit(ctx context.Context, splitter textsplitter.T...
function NewCSV (line 25) | func NewCSV(r io.Reader, columns ...string) CSV {
FILE: documentloaders/csv_test.go
function TestCSVLoader (line 12) | func TestCSVLoader(t *testing.T) {
function TestCSVLoaderWithFilteringColumns (line 34) | func TestCSVLoaderWithFilteringColumns(t *testing.T) {
FILE: documentloaders/directory.go
type Option (line 16) | type Option
function WithRoot (line 18) | func WithRoot(root string) Option {
function WithMaxDepth (line 22) | func WithMaxDepth(d int) Option {
function WithAllowExts (line 26) | func WithAllowExts(exts ...string) Option {
function WithCSVOpts (line 36) | func WithCSVOpts(cols []string) Option {
function WithPDFOpts (line 42) | func WithPDFOpts(pwd string) Option {
type RecursiveDirectoryLoader (line 47) | type RecursiveDirectoryLoader struct
method newLoader (line 71) | func (l *RecursiveDirectoryLoader) newLoader(f *os.File) (Loader, erro...
method Load (line 95) | func (l *RecursiveDirectoryLoader) Load(ctx context.Context) ([]schema...
method LoadAndSplit (line 154) | func (l *RecursiveDirectoryLoader) LoadAndSplit(ctx context.Context, s...
function NewRecursiveDirLoader (line 59) | func NewRecursiveDirLoader(opts ...Option) *RecursiveDirectoryLoader {
FILE: documentloaders/directory_test.go
function TestNewRecursiveDirLoader_Options (line 11) | func TestNewRecursiveDirLoader_Options(t *testing.T) {
function TestLoad_AllSupportedTypes (line 37) | func TestLoad_AllSupportedTypes(t *testing.T) {
FILE: documentloaders/documentloaders.go
type Loader (line 11) | type Loader interface
FILE: documentloaders/html.go
type HTML (line 15) | type HTML struct
method Load (line 27) | func (h HTML) Load(_ context.Context) ([]schema.Document, error) {
method LoadAndSplit (line 53) | func (h HTML) LoadAndSplit(ctx context.Context, splitter textsplitter....
function NewHTML (line 22) | func NewHTML(r io.Reader) HTML {
FILE: documentloaders/html_test.go
function TestHTMLLoader (line 12) | func TestHTMLLoader(t *testing.T) {
FILE: documentloaders/notion.go
type NotionDirectoryLoader (line 11) | type NotionDirectoryLoader struct
method Load (line 34) | func (n *NotionDirectoryLoader) Load() ([]schema.Document, error) {
function NewNotionDirectory (line 17) | func NewNotionDirectory(filePath string, encoding ...string) *NotionDire...
FILE: documentloaders/notion_test.go
function TestNotionDirectoryLoader_Load (line 13) | func TestNotionDirectoryLoader_Load(t *testing.T) {
FILE: documentloaders/pdf.go
type PDF (line 13) | type PDF struct
method getPassword (line 46) | func (p *PDF) getPassword() string {
method Load (line 54) | func (p PDF) Load(_ context.Context) ([]schema.Document, error) {
method LoadAndSplit (line 106) | func (p PDF) LoadAndSplit(ctx context.Context, splitter textsplitter.T...
type PDFOptions (line 22) | type PDFOptions
function WithPassword (line 25) | func WithPassword(password string) PDFOptions {
function NewPDF (line 32) | func NewPDF(r io.ReaderAt, size int64, opts ...PDFOptions) PDF {
FILE: documentloaders/pdf_test.go
function TestPDFLoader (line 14) | func TestPDFLoader(t *testing.T) {
function TestPDFTextSplit (line 93) | func TestPDFTextSplit(t *testing.T) {
FILE: documentloaders/text.go
type Text (line 13) | type Text struct
method Load (line 27) | func (l Text) Load(_ context.Context) ([]schema.Document, error) {
method LoadAndSplit (line 44) | func (l Text) LoadAndSplit(ctx context.Context, splitter textsplitter....
function NewText (line 20) | func NewText(r io.Reader) Text {
FILE: documentloaders/text_test.go
function TestTextLoader (line 12) | func TestTextLoader(t *testing.T) {
FILE: embeddings/bedrock/bedrock.go
type Bedrock (line 13) | type Bedrock struct
method EmbedDocuments (line 36) | func (b *Bedrock) EmbedDocuments(ctx context.Context, texts []string) ...
method EmbedQuery (line 67) | func (b *Bedrock) EmbedQuery(ctx context.Context, text string) ([]floa...
function NewBedrock (line 21) | func NewBedrock(opts ...Option) (*Bedrock, error) {
function getProvider (line 30) | func getProvider(modelID string) string {
FILE: embeddings/bedrock/bedrock_test.go
function TestEmbedQuery (line 14) | func TestEmbedQuery(t *testing.T) {
function TestEmbedDocuments (line 39) | func TestEmbedDocuments(t *testing.T) {
FILE: embeddings/bedrock/bedrock_unit_test.go
function TestNewBedrock (line 10) | func TestNewBedrock(t *testing.T) {
function TestBedrockOptions (line 46) | func TestBedrockOptions(t *testing.T) {
function TestGetProvider (line 73) | func TestGetProvider(t *testing.T) {
function TestDefaultValues (line 114) | func TestDefaultValues(t *testing.T) {
FILE: embeddings/bedrock/options.go
constant _defaultBatchSize (line 11) | _defaultBatchSize = 512
constant _defaultStripNewLines (line 12) | _defaultStripNewLines = true
constant _defaultModel (line 13) | _defaultModel = ModelTitanEmbedG1
type Option (line 17) | type Option
function WithStripNewLines (line 20) | func WithStripNewLines(stripNewLines bool) Option {
function WithBatchSize (line 28) | func WithBatchSize(batchSize int) Option {
function WithModel (line 35) | func WithModel(model string) Option {
function WithClient (line 42) | func WithClient(client *bedrockruntime.Client) Option {
function applyOptions (line 48) | func applyOptions(opts ...Option) (*Bedrock, error) {
FILE: embeddings/bedrock/provider_amazon.go
constant ModelTitanEmbedG1 (line 19) | ModelTitanEmbedG1 = "amazon.titan-embed-text-v1"
type amazonEmbeddingsInput (line 22) | type amazonEmbeddingsInput struct
type amazonEmbeddingsOutput (line 26) | type amazonEmbeddingsOutput struct
function FetchAmazonTextEmbeddings (line 30) | func FetchAmazonTextEmbeddings(ctx context.Context,
FILE: embeddings/bedrock/provider_cohere.go
constant ModelCohereEn (line 19) | ModelCohereEn = "cohere.embed-english-v3"
constant ModelCohereMulti (line 28) | ModelCohereMulti = "cohere.embed-multilingual-v3"
constant CohereInputTypeText (line 33) | CohereInputTypeText = "search_document"
constant CohereInputTypeQuery (line 35) | CohereInputTypeQuery = "search_query"
type cohereTextEmbeddingsInput (line 38) | type cohereTextEmbeddingsInput struct
type cohereTextEmbeddingsOutput (line 43) | type cohereTextEmbeddingsOutput struct
function FetchCohereTextEmbeddings (line 48) | func FetchCohereTextEmbeddings(
FILE: embeddings/cybertron/cybertron.go
type Cybertron (line 12) | type Cybertron struct
method CreateEmbedding (line 31) | func (c *Cybertron) CreateEmbedding(ctx context.Context, texts []strin...
function NewCybertron (line 25) | func NewCybertron(opts ...Option) (*Cybertron, error) {
FILE: embeddings/cybertron/cybertron_test.go
function TestCybertronEmbeddings (line 11) | func TestCybertronEmbeddings(t *testing.T) {
FILE: embeddings/cybertron/cybertron_unit_test.go
function TestOptions (line 10) | func TestOptions(t *testing.T) {
function TestDefaultValues (line 33) | func TestDefaultValues(t *testing.T) {
function TestApplyOptions (line 39) | func TestApplyOptions(t *testing.T) {
FILE: embeddings/cybertron/options.go
constant _defaultModel (line 10) | _defaultModel = "sentence-transformers/all-MiniLM-L6-v2"
constant _defaultModelsDir (line 11) | _defaultModelsDir = "models"
constant _defaultPoolingStrategy (line 12) | _defaultPoolingStrategy = bert.MeanPooling
type Option (line 16) | type Option
method apply (line 19) | func (o Option) apply(c *Cybertron) {
function WithModel (line 26) | func WithModel(model string) Option {
function WithModelsDir (line 34) | func WithModelsDir(dir string) Option {
function WithPoolingStrategy (line 41) | func WithPoolingStrategy(strategy bert.PoolingStrategyType) Option {
function WithEncoder (line 48) | func WithEncoder(encoder textencoding.Interface) Option {
function applyOptions (line 54) | func applyOptions(opts ...Option) (*Cybertron, error) {
FILE: embeddings/embedding.go
function NewEmbedder (line 13) | func NewEmbedder(client EmbedderClient, opts ...Option) (*EmbedderImpl, ...
type Embedder (line 27) | type Embedder interface
type EmbedderClient (line 35) | type EmbedderClient interface
type EmbedderClientFunc (line 42) | type EmbedderClientFunc
method CreateEmbedding (line 44) | func (e EmbedderClientFunc) CreateEmbedding(ctx context.Context, texts...
type EmbedderImpl (line 48) | type EmbedderImpl struct
method EmbedQuery (line 56) | func (ei *EmbedderImpl) EmbedQuery(ctx context.Context, text string) (...
method EmbedDocuments (line 70) | func (ei *EmbedderImpl) EmbedDocuments(ctx context.Context, texts []st...
function MaybeRemoveNewLines (line 75) | func MaybeRemoveNewLines(texts []string, removeNewLines bool) []string {
function BatchTexts (line 88) | func BatchTexts(texts []string, batchSize int) [][]string {
function BatchedEmbed (line 100) | func BatchedEmbed(ctx context.Context, embedder EmbedderClient, texts []...
FILE: embeddings/embedding_test.go
function TestBatchTexts (line 9) | func TestBatchTexts(t *testing.T) {
FILE: embeddings/example_test.go
function Example (line 11) | func Example() { //nolint:testableexamples
FILE: embeddings/huggingface/huggingface.go
type Huggingface (line 12) | type Huggingface struct
method EmbedDocuments (line 32) | func (e *Huggingface) EmbedDocuments(ctx context.Context, texts []stri...
method EmbedQuery (line 50) | func (e *Huggingface) EmbedQuery(ctx context.Context, text string) ([]...
function NewHuggingface (line 23) | func NewHuggingface(opts ...Option) (*Huggingface, error) {
FILE: embeddings/huggingface/huggingface_test.go
function TestHuggingfaceEmbeddings (line 14) | func TestHuggingfaceEmbeddings(t *testing.T) {
FILE: embeddings/huggingface/huggingface_unit_test.go
function TestOptions (line 10) | func TestOptions(t *testing.T) {
function TestDefaultValues (line 45) | func TestDefaultValues(t *testing.T) {
function TestNewHuggingface (line 52) | func TestNewHuggingface(t *testing.T) {
FILE: embeddings/huggingface/options.go
constant _defaultBatchSize (line 8) | _defaultBatchSize = 512
constant _defaultStripNewLines (line 9) | _defaultStripNewLines = true
constant _defaultModel (line 10) | _defaultModel = "BAAI/bge-small-en-v1.5"
constant _defaultTask (line 11) | _defaultTask = "feature-extraction"
type Option (line 15) | type Option
function WithModel (line 18) | func WithModel(model string) Option {
function WithTask (line 25) | func WithTask(task string) Option {
function WithClient (line 32) | func WithClient(client huggingface.LLM) Option {
function WithStripNewLines (line 39) | func WithStripNewLines(stripNewLines bool) Option {
function WithBatchSize (line 46) | func WithBatchSize(batchSize int) Option {
function applyOptions (line 52) | func applyOptions(opts ...Option) (*Huggingface, error) {
FILE: embeddings/jina/jina.go
type Jina (line 15) | type Jina struct
method EmbedDocuments (line 52) | func (j *Jina) EmbedDocuments(ctx context.Context, texts []string) ([]...
method EmbedQuery (line 70) | func (j *Jina) EmbedQuery(ctx context.Context, text string) ([]float32...
method CreateEmbedding (line 84) | func (j *Jina) CreateEmbedding(ctx context.Context, texts []string) ([...
type EmbeddingRequest (line 25) | type EmbeddingRequest struct
type EmbeddingResponse (line 30) | type EmbeddingResponse struct
function NewJina (line 46) | func NewJina(opts ...Option) (*Jina, error) {
FILE: embeddings/jina/jina_test.go
function TestJina_EmbedDocuments (line 13) | func TestJina_EmbedDocuments(t *testing.T) {
function TestJina_EmbedQuery (line 46) | func TestJina_EmbedQuery(t *testing.T) {
function TestJina_WithBatchSize (line 72) | func TestJina_WithBatchSize(t *testing.T) {
function TestJina_StripNewLines (line 109) | func TestJina_StripNewLines(t *testing.T) {
FILE: embeddings/jina/jina_unit_test.go
function TestNewJina (line 14) | func TestNewJina(t *testing.T) { //nolint:funlen // comprehensive test
function TestJinaOptions (line 194) | func TestJinaOptions(t *testing.T) {
function TestJina_EmbedQuery_Error (line 233) | func TestJina_EmbedQuery_Error(t *testing.T) {
function TestJina_EmbedDocuments_Error (line 256) | func TestJina_EmbedDocuments_Error(t *testing.T) {
function TestApplyOptions (line 280) | func TestApplyOptions(t *testing.T) {
FILE: embeddings/jina/options.go
constant _defaultStripNewLines (line 11) | _defaultStripNewLines = true
constant _defaultModel (line 12) | _defaultModel = "jina-embeddings-v2-small-en"
constant _defaultTask (line 13) | _defaultTask = "feature-extraction"
constant SmallModel (line 14) | SmallModel = "jina-embeddings-v2-small-en"
constant BaseModel (line 15) | BaseModel = "jina-embeddings-v2-base-en"
constant LargeModel (line 16) | LargeModel = "jina-embeddings-v2-large-en"
constant APIBaseURL (line 17) | APIBaseURL = "https://api.jina.ai/v1/embeddings"
type Option (line 21) | type Option
function WithModel (line 24) | func WithModel(model string) Option {
function WithStripNewLines (line 31) | func WithStripNewLines(stripNewLines bool) Option {
function WithBatchSize (line 38) | func WithBatchSize(batchSize int) Option {
function WithAPIBaseURL (line 45) | func WithAPIBaseURL(apiBaseURL string) Option {
function WithAPIKey (line 52) | func WithAPIKey(apiKey string) Option {
function WithClient (line 59) | func WithClient(client *http.Client) Option {
function applyOptions (line 65) | func applyOptions(opts ...Option) *Jina {
FILE: embeddings/openai_test.go
function newOpenAIEmbedder (line 15) | func newOpenAIEmbedder(t *testing.T, opts ...Option) *EmbedderImpl {
function TestOpenaiEmbeddings (line 44) | func TestOpenaiEmbeddings(t *testing.T) {
function TestOpenaiEmbeddingsQueryVsDocuments (line 56) | func TestOpenaiEmbeddingsQueryVsDocuments(t *testing.T) {
function TestOpenaiEmbeddingsWithOptions (line 74) | func TestOpenaiEmbeddingsWithOptions(t *testing.T) {
function TestOpenaiEmbeddingsWithAzureAPI (line 87) | func TestOpenaiEmbeddingsWithAzureAPI(t *testing.T) {
FILE: embeddings/options.go
constant defaultBatchSize (line 4) | defaultBatchSize = 512
constant defaultStripNewLines (line 5) | defaultStripNewLines = true
type Option (line 8) | type Option
function WithStripNewLines (line 11) | func WithStripNewLines(stripNewLines bool) Option {
function WithBatchSize (line 18) | func WithBatchSize(batchSize int) Option {
FILE: embeddings/vector_math.go
function CombineVectors (line 17) | func CombineVectors(vectors [][]float32, weights []int) ([]float32, erro...
function getAverage (line 34) | func getAverage(vectors [][]float32, weights []int) ([]float32, error) {
function getNorm (line 76) | func getNorm(v []float32) float32 {
FILE: embeddings/vector_math_test.go
function TestCombineVectors (line 9) | func TestCombineVectors(t *testing.T) {
function TestGetAverage (line 39) | func TestGetAverage(t *testing.T) {
function TestGetNorm (line 81) | func TestGetNorm(t *testing.T) {
FILE: embeddings/voyageai/options.go
constant _defaultBaseURL (line 12) | _defaultBaseURL = "https://api.voyageai.com/v1"
constant _defaultBatchSize (line 13) | _defaultBatchSize = 512
constant _defaultStripNewLines (line 14) | _defaultStripNewLines = true
constant _defaultModel (line 15) | _defaultModel = "voyage-2"
type Option (line 19) | type Option
function WithModel (line 22) | func WithModel(model string) Option {
function WithClient (line 30) | func WithClient(client http.Client) Option {
function WithToken (line 37) | func WithToken(token string) Option {
function WithStripNewLines (line 44) | func WithStripNewLines(stripNewLines bool) Option {
function WithBatchSize (line 51) | func WithBatchSize(batchSize int) Option {
function applyOptions (line 57) | func applyOptions(opts ...Option) (*VoyageAI, error) {
FILE: embeddings/voyageai/voyageai.go
type VoyageAI (line 16) | type VoyageAI struct
method EmbedDocuments (line 48) | func (v *VoyageAI) EmbedDocuments(ctx context.Context, texts []string)...
method EmbedQuery (line 91) | func (v *VoyageAI) EmbedQuery(ctx context.Context, text string) ([]flo...
method request (line 114) | func (v *VoyageAI) request(ctx context.Context, path string, body any)...
method decodeError (line 131) | func (v *VoyageAI) decodeError(resp *http.Response) error {
function NewVoyageAI (line 27) | func NewVoyageAI(opts ...Option) (*VoyageAI, error) {
type embeddingResponse (line 35) | type embeddingResponse struct
type embedDocumentsRequest (line 41) | type embedDocumentsRequest struct
type embedQueryRequest (line 84) | type embedQueryRequest struct
FILE: embeddings/voyageai/voyageai_test.go
function TestVoyageAI_EmbedDocuments (line 15) | func TestVoyageAI_EmbedDocuments(t *testing.T) {
function TestVoyageAI_EmbedQuery (line 58) | func TestVoyageAI_EmbedQuery(t *testing.T) {
function TestVoyageAI_WithBatchSize (line 94) | func TestVoyageAI_WithBatchSize(t *testing.T) {
function TestVoyageAI_WithModel (line 141) | func TestVoyageAI_WithModel(t *testing.T) {
FILE: embeddings/voyageai/voyageai_unit_test.go
function TestNewVoyageAI (line 14) | func TestNewVoyageAI(t *testing.T) { //nolint:funlen // comprehensive test
function TestVoyageAIOptions (line 164) | func TestVoyageAIOptions(t *testing.T) {
function TestVoyageAI_EmbedQuery_InvalidURL (line 197) | func TestVoyageAI_EmbedQuery_InvalidURL(t *testing.T) {
function TestVoyageAI_EmbedDocuments_InvalidURL (line 214) | func TestVoyageAI_EmbedDocuments_InvalidURL(t *testing.T) {
function TestApplyOptions (line 231) | func TestApplyOptions(t *testing.T) {
FILE: examples/anthropic-completion-example/anthropic_completion_example.go
function main (line 12) | func main() {
FILE: examples/anthropic-extended-capabilities/main.go
function main (line 13) | func main() {
FILE: examples/anthropic-interleaved-thinking/main.go
type debugTransport (line 151) | type debugTransport struct
method RoundTrip (line 156) | func (d *debugTransport) RoundTrip(req *http.Request) (*http.Response,...
function main (line 192) | func main() {
function convertToolCallsToParts (line 633) | func convertToolCallsToParts(toolCalls []llms.ToolCall) []llms.ContentPa...
function executeToolCall (line 646) | func executeToolCall(name string, arguments string) string {
FILE: examples/anthropic-tool-call-example/anthropic-tool-call-example.go
function main (line 14) | func main() {
function executeToolCalls (line 95) | func executeToolCalls(ctx context.Context, llm llms.Model, messageHistor...
function getCurrentWeather (line 152) | func getCurrentWeather(location string, unit string) (string, error) {
FILE: examples/anthropic-vision-example/anthropic_vision_example.go
function main (line 16) | func main() {
FILE: examples/bedrock-claude3-vision-example/becrock_claude3_vision_example.go
function main (line 16) | func main() {
FILE: examples/bedrock-provider-example/main.go
function main (line 13) | func main() {
FILE: examples/caching-llm-example/caching_llm_example.go
constant WIDTH (line 17) | WIDTH = 80
function main (line 19) | func main() {
FILE: examples/chains-conversation-memory-sqlite/chains_conversation_memory_sqlite.go
function main (line 18) | func main() {
function prepare (line 25) | func prepare(ctx context.Context, db *sql.DB) error {
function run (line 51) | func run() error {
FILE: examples/chroma-vectorstore-example/chroma_vectorstore_example.go
function main (line 17) | func main() {
FILE: examples/cohere-llm-example/cohere_completion_example.go
function main (line 12) | func main() {
FILE: examples/cybertron-embedding-example/cybertron-embedding.go
function cosineSimilarity (line 19) | func cosineSimilarity(x, y []float32) float32 {
function randomIndexName (line 35) | func randomIndexName() string {
function exampleInMemory (line 39) | func exampleInMemory(ctx context.Context, emb embeddings.Embedder) {
function exampleWeaviate (line 62) | func exampleWeaviate(ctx context.Context, emb embeddings.Embedder) {
function main (line 110) | func main() {
FILE: examples/deepseek-completion-example/deepseek-completion-example.go
function main (line 12) | func main() {
FILE: examples/document-qa-example/document_qa.go
function main (line 13) | func main() {
function run (line 20) | func run() error {
FILE: examples/ernie-chat-example/ernie_chat_example.go
function main (line 12) | func main() {
FILE: examples/ernie-completion-example/ernie_completion_example.go
function main (line 13) | func main() {
FILE: examples/ernie-function-call-example/ernie_function_call_example.go
function main (line 14) | func main() {
function getCurrentWeather (line 42) | func getCurrentWeather(location string, unit string) (string, error) {
FILE: examples/google-alloydb-chat-message-history-example/google_alloydb_chat_message_history_example.go
function getEnvVariables (line 16) | func getEnvVariables() (string, string, string, string, string, string, ...
function printMessages (line 66) | func printMessages(ctx context.Context, cmh alloydb.ChatMessageHistory) {
function main (line 76) | func main() {
FILE: examples/google-alloydb-vectorstore-example/google_alloydb_vectorstore_example.go
function getEnvVariables (line 18) | func getEnvVariables() (string, string, string, string, string, string, ...
function main (line 69) | func main() {
FILE: examples/google-cloudsql-chat-message-history-example/google_cloudsql_chat_message_history_example.go
function getEnvVariables (line 16) | func getEnvVariables() (string, string, string, string, string, string, ...
function printMessages (line 61) | func printMessages(ctx context.Context, cmh cloudsql.ChatMessageHistory) {
function main (line 71) | func main() {
FILE: examples/google-cloudsql-vectorstore-example/google_cloudsql_vectorstore_example.go
function getEnvVariables (line 18) | func getEnvVariables() (string, string, string, string, string, string, ...
function main (line 64) | func main() {
FILE: examples/googleai-completion-example/googleai-completion-example.go
function main (line 14) | func main() {
FILE: examples/googleai-reasoning-caching/main.go
function main (line 16) | func main() {
function demonstrateReasoning (line 38) | func demonstrateReasoning(ctx context.Context, apiKey string) {
function demonstrateCaching (line 91) | func demonstrateCaching(ctx context.Context, apiKey string) {
function setupCachingHelper (line 102) | func setupCachingHelper(ctx context.Context, apiKey string) *googleai.Ca...
function createCachedContent (line 110) | func createCachedContent(ctx context.Context, helper *googleai.CachingHe...
function runCachedRequests (line 148) | func runCachedRequests(ctx context.Context, apiKey, cachedContentName st...
FILE: examples/googleai-streaming-example/googleai-stremaing-example.go
function main (line 14) | func main() {
FILE: examples/googleai-tool-call-example/googleai-tool-call-example.go
function main (line 15) | func main() {
FILE: examples/groq-completion-example/groq_completion_example.go
function main (line 13) | func main() {
FILE: examples/huggingface-llm-example/huggingface_example.go
function main (line 12) | func main() {
FILE: examples/huggingface-milvus-vectorstore-example/milvus_vectorstore_example.go
constant poolSize (line 20) | poolSize = 5
constant baseURL (line 21) | baseURL = "http://localhost:5500"
function main (line 24) | func main() {
function newStore (line 32) | func newStore() (vectorstores.VectorStore, error) {
function citiesExample (line 63) | func citiesExample(store vectorstores.VectorStore) {
FILE: examples/json-mode-example/json_mode_example.go
function main (line 18) | func main() {
function initBackend (line 38) | func initBackend(ctx context.Context) (llms.Model, error) {
FILE: examples/llamafile-completion-example/llamafile_completion_example.go
function main (line 11) | func main() {
FILE: examples/llm-chain-example/llm_chain.go
function main (line 13) | func main() {
function run (line 20) | func run() error {
FILE: examples/llmmath-chain-example/llm_math_chain.go
function main (line 12) | func main() {
function run (line 19) | func run() error {
FILE: examples/llmsummarization-chain-example/llm_summarization_example.go
function main (line 15) | func main() {
FILE: examples/local-llm-example/local_llm_example.go
function main (line 12) | func main() {
FILE: examples/maritaca-example/maritaca-chat-example.go
function main (line 11) | func main() {
FILE: examples/mistral-completion-example/mistral_completion_example.go
function main (line 12) | func main() {
FILE: examples/mistral-embedding-example/mistral-embedding-example.go
function main (line 17) | func main() {
FILE: examples/mistral-summarization-example/mistral_summarization_example.go
function main (line 15) | func main() {
FILE: examples/mongovector-vectorstore-example/mongovector_vectorstore_example.go
function main (line 20) | func main() {
type vectorField (line 188) | type vectorField struct
function createVectorSearchIndex (line 198) | func createVectorSearchIndex(
function searchIndexExists (line 243) | func searchIndexExists(ctx context.Context, coll *mongo.Collection, idx ...
FILE: examples/mrkl-agent-example/mrkl_agent.go
function main (line 15) | func main() {
function run (line 22) | func run() error {
FILE: examples/nvidia-chat-completion/nvidia_chat_completion_example.go
function main (line 13) | func main() {
FILE: examples/ollama-chat-example/ollama_chat_example.go
function main (line 12) | func main() {
FILE: examples/ollama-chroma-vectorstore-example/chroma_vectorstore_example.go
function main (line 18) | func main() {
FILE: examples/ollama-completion-example/ollama_completion_example.go
function main (line 12) | func main() {
FILE: examples/ollama-functions-example/ollama_functions_example.go
function main (line 18) | func main() {
type Call (line 74) | type Call struct
function unmarshalCall (line 79) | func unmarshalCall(input string) *Call {
function dispatchCall (line 87) | func dispatchCall(c *Call) (llms.MessageContent, bool) {
function validTool (line 128) | func validTool(name string) bool {
function systemMessage (line 136) | func systemMessage() string {
function getCurrentWeather (line 154) | func getCurrentWeather(location string, unit string) (string, error) {
FILE: examples/ollama-reasoning-caching/main.go
function main (line 15) | func main() {
function demonstrateReasoning (line 38) | func demonstrateReasoning(ctx context.Context, serverURL string) {
function demonstrateCaching (line 117) | func demonstrateCaching(ctx context.Context, serverURL string) {
function setupCachingClient (line 127) | func setupCachingClient(serverURL string) (llms.Model, *ollama.ContextCa...
function runCachingDemo (line 144) | func runCachingDemo(ctx context.Context, llm llms.Model, cache *ollama.C...
function processQuestion (line 173) | func processQuestion(ctx context.Context, llm llms.Model, cache *ollama....
FILE: examples/ollama-stream-example/ollama_stream_example.go
function main (line 12) | func main() {
FILE: examples/openai-chat-example/openai_chat_example.go
function main (line 12) | func main() {
FILE: examples/openai-completion-example-with-http-debugging/openai_completion_example.go
function main (line 16) | func main() {
FILE: examples/openai-completion-example/openai_completion_example.go
function main (line 12) | func main() {
FILE: examples/openai-embeddings-example/openai-embeddings-example.go
function main (line 11) | func main() {
FILE: examples/openai-function-call-example/openai_function_call_example.go
function main (line 14) | func main() {
function updateMessageHistory (line 49) | func updateMessageHistory(messageHistory []llms.MessageContent, resp *ll...
function executeToolCalls (line 61) | func executeToolCalls(ctx context.Context, llm llms.Model, messageHistor...
function getCurrentWeather (line 98) | func getCurrentWeather(location string, unit string) (string, error) {
function showResponse (line 143) | func showResponse(resp *llms.ContentResponse) string {
FILE: examples/openai-function-call-streaming-example/openai_function_call_example.go
function main (line 14) | func main() {
function getCurrentWeather (line 39) | func getCurrentWeather(location string, unit string) (string, error) {
FILE: examples/openai-gpt4-turbo-example/openai_gpt4_turbo.go
function main (line 12) | func main() {
FILE: examples/openai-gpt4o-example/openai_gpt4o_example.go
function main (line 12) | func main() {
FILE: examples/openai-gpt4o-mutil-content/openai-gpt4o-mutil-content.go
function main (line 12) | func main() {
FILE: examples/openai-jsonformat-example/openai-jsonformat.go
type User (line 11) | type User struct
function main (line 16) | func main() {
FILE: examples/openai-o1-example/openai_o1_chat_example.go
function main (line 17) | func main() {
FILE: examples/openai-readme/openai-readme.go
function main (line 12) | func main() {
FILE: examples/openrouter-llm-example/openrouter_llm_example.go
function main (line 15) | func main() {
FILE: examples/perplexity-completion-example/perplexity_completion_example.go
function main (line 14) | func main() {
FILE: examples/pgvector-vectorstore-example/pgvector_vectorstore_example.go
function main (line 16) | func main() {
FILE: examples/pinecone-vectorstore-example/pinecone_vectorstore_example.go
function main (line 16) | func main() {
FILE: examples/postgresql-database-chain-example/postgresql_database_chain.go
function main (line 16) | func main() {
function makeSample (line 23) | func makeSample(dsn string) {
function run (line 75) | func run() error {
FILE: examples/prompt-caching/main.go
function main (line 13) | func main() {
type CacheUsage (line 217) | type CacheUsage struct
function extractCacheUsage (line 226) | func extractCacheUsage(genInfo map[string]any) *CacheUsage {
FILE: examples/prompt-template-example/main.go
function main (line 10) | func main() {
FILE: examples/qdrant-vectorstore-example/qdrant_vectorstore_example.go
function main (line 16) | func main() {
FILE: examples/reasoning-tokens/main.go
function main (line 14) | func main() {
function testReasoning (line 88) | func testReasoning(ctx context.Context, llm llms.Model, modelName string...
FILE: examples/redis-vectorstore-example/redis_vectorstore_example.go
function main (line 19) | func main() {
function getEmbedding (line 68) | func getEmbedding(model string, connectionStr ...string) (llms.Model, *e...
FILE: examples/sequential-chain-example/sequential_chain_example.go
function main (line 13) | func main() {
function simpleSequentialChainExample (line 20) | func simpleSequentialChainExample() {
function sequentialChainExample (line 56) | func sequentialChainExample() {
FILE: examples/sql-database-chain-example/sql_database_chain.go
function main (line 16) | func main() {
function makeSample (line 23) | func makeSample(dsn string) {
function run (line 75) | func run() error {
FILE: examples/tutorial-basic-chat-app/main.go
function main (line 17) | func main() {
function runBasicChat (line 39) | func runBasicChat() {
function runInteractiveChat (line 65) | func runInteractiveChat() {
function runChatWithMemory (line 100) | func runChatWithMemory() {
function runAdvancedChat (line 154) | func runAdvancedChat() {
FILE: examples/tutorial-basic-chat-app/step3_basic.go
function basicChat (line 13) | func basicChat() {
FILE: examples/tutorial-basic-chat-app/step4_interactive.go
function interactiveChat (line 16) | func interactiveChat() {
FILE: examples/tutorial-basic-chat-app/step5_memory.go
function chatWithMemory (line 17) | func chatWithMemory() {
FILE: examples/tutorial-basic-chat-app/step6_advanced.go
function advancedChat (line 17) | func advancedChat() {
FILE: examples/vertex-completion-example/vertex-completion-example.go
function main (line 19) | func main() {
FILE: examples/vertex-embedding-example/vertex-embedding-example.go
function main (line 16) | func main() {
FILE: examples/watsonx-llm-example/watsonx_example.go
function main (line 12) | func main() {
FILE: examples/zapier-llm-example/main.go
function main (line 14) | func main() {
FILE: examples/zep-memory-chain-example/main.go
function main (line 16) | func main() {
FILE: httputil/logging_transport.go
type LoggingTransport (line 66) | type LoggingTransport struct
method RoundTrip (line 80) | func (t *LoggingTransport) RoundTrip(req *http.Request) (*http.Respons...
constant colorBlue (line 113) | colorBlue = "\033[34m"
constant colorGreen (line 114) | colorGreen = "\033[32m"
constant colorYellow (line 115) | colorYellow = "\033[33m"
constant colorPurple (line 116) | colorPurple = "\033[35m"
constant colorGrey (line 117) | colorGrey = "\033[90m"
constant colorReset (line 118) | colorReset = "\033[0m"
type jsonDebugTransport (line 121) | type jsonDebugTransport struct
method RoundTrip (line 137) | func (t *jsonDebugTransport) RoundTrip(req *http.Request) (*http.Respo...
method wrapSSEResponse (line 183) | func (t *jsonDebugTransport) wrapSSEResponse(resp *http.Response) *htt...
method parseEvent (line 224) | func (t *jsonDebugTransport) parseEvent(text string) {
method logJSON (line 261) | func (t *jsonDebugTransport) logJSON(contentType string, body *io.Read...
method printUsage (line 278) | func (t *jsonDebugTransport) printUsage(usage map[string]interface{}) {
function scrubSensitive (line 125) | func scrubSensitive(key, value string) string {
FILE: httputil/transport.go
type Transport (line 32) | type Transport struct
method RoundTrip (line 42) | func (t *Transport) RoundTrip(req *http.Request) (*http.Response, erro...
type ApiKeyTransport (line 67) | type ApiKeyTransport struct
method RoundTrip (line 78) | func (t *ApiKeyTransport) RoundTrip(req *http.Request) (*http.Response...
FILE: httputil/transport_test.go
type mockRoundTripper (line 13) | type mockRoundTripper struct
method RoundTrip (line 19) | func (m *mockRoundTripper) RoundTrip(req *http.Request) (*http.Respons...
function TestTransport_RoundTrip (line 30) | func TestTransport_RoundTrip(t *testing.T) {
function TestTransport_NilTransport (line 88) | func TestTransport_NilTransport(t *testing.T) {
function TestDefaultTransport (line 107) | func TestDefaultTransport(t *testing.T) {
function TestDefaultClient (line 117) | func TestDefaultClient(t *testing.T) {
function TestApiKeyTransport_RoundTrip (line 136) | func TestApiKeyTransport_RoundTrip(t *testing.T) {
function TestApiKeyTransport_NilTransport (line 207) | func TestApiKeyTransport_NilTransport(t *testing.T) {
function TestApiKeyTransport_PreservesOtherParams (line 228) | func TestApiKeyTransport_PreservesOtherParams(t *testing.T) {
FILE: httputil/useragent.go
function UserAgent (line 19) | func UserAgent() string {
FILE: httputil/useragent_test.go
function TestUserAgent (line 10) | func TestUserAgent(t *testing.T) {
function TestUserAgentFormat (line 33) | func TestUserAgentFormat(t *testing.T) {
function TestUserAgentComponents (line 47) | func TestUserAgentComponents(t *testing.T) {
FILE: internal/devtools/examples-updater/main.go
function main (line 21) | func main() {
function updateExamples (line 44) | func updateExamples(newVersion string, dryRun bool) error {
function findGoModFiles (line 129) | func findGoModFiles(root string) ([]string, error) {
function removeReplaceDirective (line 143) | func removeReplaceDirective(content string) string {
FILE: internal/devtools/lint/lint.go
function main (line 32) | func main() {
function changeToRepoRoot (line 51) | func changeToRepoRoot() error {
function run (line 112) | func run(fix bool) error {
function mapKeys (line 163) | func mapKeys(m map[string]bool) []string {
function checkMissingExampleGoModFiles (line 172) | func checkMissingExampleGoModFiles(fix bool) error {
function fixMissingExampleGoModFile (line 203) | func fixMissingExampleGoModFile(dir string) error {
function checkModuleNameMatchesDirectory (line 216) | func checkModuleNameMatchesDirectory(fix bool) error {
function fixModuleName (line 309) | func fixModuleName(dir, expectedModuleName string) error {
function checkMissingReplaceDirectives (line 325) | func checkMissingReplaceDirectives(fix bool) error {
function fixAddReplaceDirective (line 429) | func fixAddReplaceDirective(dir, rootModName string) error {
function checkNoReplaceDirectives (line 463) | func checkNoReplaceDirectives(fix bool) error {
function fixRemoveReplaceDirectives (line 531) | func fixRemoveReplaceDirectives(dir string) error {
function checkHttprrCompression (line 564) | func checkHttprrCompression(fix bool) error {
function checkHttprrTestPatterns (line 655) | func checkHttprrTestPatterns(fix bool) error {
type HttprrIssue (line 812) | type HttprrIssue struct
type HttprrIssueType (line 821) | type HttprrIssueType
constant IssueHardcodedToken (line 824) | IssueHardcodedToken HttprrIssueType = iota
constant IssueParallelBeforeHttprr (line 825) | IssueParallelBeforeHttprr
constant IssueRedundantCleanup (line 826) | IssueRedundantCleanup
constant IssueDirectOsGetenv (line 827) | IssueDirectOsGetenv
constant IssueNotRecordingPattern (line 828) | IssueNotRecordingPattern
function analyzeHttprrPatternsInFile (line 832) | func analyzeHttprrPatternsInFile(filePath string) ([]HttprrIssue, error) {
type HttprrAnalyzer (line 865) | type HttprrAnalyzer struct
method Visit (line 876) | func (a *HttprrAnalyzer) Visit(node ast.Node) ast.Visitor {
method isHttprrOpenForTest (line 934) | func (a *HttprrAnalyzer) isHttprrOpenForTest(call *ast.CallExpr) bool {
method isWithTokenCall (line 944) | func (a *HttprrAnalyzer) isWithTokenCall(call *ast.CallExpr) bool {
method isRecordingCheck (line 961) | func (a *HttprrAnalyzer) isRecordingCheck(ifStmt *ast.IfStmt) bool {
method isNotRecordingCheck (line 986) | func (a *HttprrAnalyzer) isNotRecordingCheck(ifStmt *ast.IfStmt) bool {
method checkNotRecordingUsage (line 1006) | func (a *HttprrAnalyzer) checkNotRecordingUsage(ifStmt *ast.IfStmt) {
method checkTokenUsage (line 1018) | func (a *HttprrAnalyzer) checkTokenUsage(call *ast.CallExpr) {
method checkParallelUsage (line 1033) | func (a *HttprrAnalyzer) checkParallelUsage(fn *ast.FuncDecl) {
method isCleanupCall (line 1083) | func (a *HttprrAnalyzer) isCleanupCall(call *ast.CallExpr) bool {
method checkCleanupUsage (line 1093) | func (a *HttprrAnalyzer) checkCleanupUsage(call *ast.CallExpr) {
method containsRRClose (line 1122) | func (a *HttprrAnalyzer) containsRRClose(stmt ast.Stmt) bool {
method isOsGetenvCall (line 1141) | func (a *HttprrAnalyzer) isOsGetenvCall(call *ast.CallExpr) bool {
method checkOsGetenvUsage (line 1151) | func (a *HttprrAnalyzer) checkOsGetenvUsage(call *ast.CallExpr) {
method isCredentialEnvVar (line 1187) | func (a *HttprrAnalyzer) isCredentialEnvVar(envVar string) bool {
method hasTrailingComment (line 1217) | func (a *HttprrAnalyzer) hasTrailingComment(call *ast.CallExpr) bool {
method isInRecordingCondition (line 1238) | func (a *HttprrAnalyzer) isInRecordingCondition(call *ast.CallExpr) bo...
method statementContainsRecordingCall (line 1265) | func (a *HttprrAnalyzer) statementContainsRecordingCall(stmt ast.Stmt)...
function fixHttprrPatternsInFileAST (line 1284) | func fixHttprrPatternsInFileAST(filePath string, issues []HttprrIssue) e...
type HttprrFixer (line 1322) | type HttprrFixer struct
method containsRRClose (line 1328) | func (f *HttprrFixer) containsRRClose(stmt ast.Stmt) bool {
method Visit (line 1347) | func (f *HttprrFixer) Visit(node ast.Node) ast.Visitor {
method fixParallelUsageInFunction (line 1373) | func (f *HttprrFixer) fixParallelUsageInFunction(fn *ast.FuncDecl) {
method fixRedundantCleanupInFunction (line 1420) | func (f *HttprrFixer) fixRedundantCleanupInFunction(fn *ast.FuncDecl) {
method fixTokenUsageInCall (line 1478) | func (f *HttprrFixer) fixTokenUsageInCall(call *ast.CallExpr) {
method fixNotRecordingPattern (line 1493) | func (f *HttprrFixer) fixNotRecordingPattern(ifStmt *ast.IfStmt) {
function checkArchitecturalRules (line 1527) | func checkArchitecturalRules(fix bool) error {
type ArchitecturalIssueType (line 1642) | type ArchitecturalIssueType
constant IssueDirectHttpClientUsage (line 1645) | IssueDirectHttpClientUsage ArchitecturalIssueType = iota
constant IssueProviderCrossDependency (line 1646) | IssueProviderCrossDependency
constant IssueMissingOptionsPattern (line 1647) | IssueMissingOptionsPattern
constant IssueInterfaceViolation (line 1648) | IssueInterfaceViolation
constant IssueTestPlacement (line 1649) | IssueTestPlacement
constant IssueInternalPackageUsage (line 1650) | IssueInternalPackageUsage
constant IssueTestHttpClientUsage (line 1651) | IssueTestHttpClientUsage
constant IssueTestMissingHttprr (line 1652) | IssueTestMissingHttprr
constant IssueTestHttpGetUsage (line 1653) | IssueTestHttpGetUsage
constant IssueTestHttpClientModification (line 1654) | IssueTestHttpClientModification
constant IssueTestProviderConstructorWithoutHttprr (line 1655) | IssueTestProviderConstructorWithoutHttprr
constant IssueTestHardcodedApiUrl (line 1656) | IssueTestHardcodedApiUrl
constant IssueTestSkipsHttprrCheck (line 1657) | IssueTestSkipsHttprrCheck
type ArchitecturalIssue (line 1661) | type ArchitecturalIssue struct
function shouldSkipArchitecturalCheck (line 1670) | func shouldSkipArchitecturalCheck(file string) bool {
function checkArchitecturalRulesInFile (line 1690) | func checkArchitecturalRulesInFile(filePath string) ([]ArchitecturalIssu...
type ArchitecturalAnalyzer (line 1718) | type ArchitecturalAnalyzer struct
method Visit (line 1728) | func (a *ArchitecturalAnalyzer) Visit(node ast.Node) ast.Visitor {
method checkImportUsage (line 1755) | func (a *ArchitecturalAnalyzer) checkImportUsage(imp *ast.ImportSpec) {
method checkHttpClientUsage (line 1798) | func (a *ArchitecturalAnalyzer) checkHttpClientUsage(sel *ast.Selector...
method checkOptionsPatternUsage (line 1837) | func (a *ArchitecturalAnalyzer) checkOptionsPatternUsage(call *ast.Cal...
method checkConstructorPattern (line 1862) | func (a *ArchitecturalAnalyzer) checkConstructorPattern(fn *ast.FuncDe...
method checkInterfaceCompliance (line 1899) | func (a *ArchitecturalAnalyzer) checkInterfaceCompliance(fn *ast.FuncD...
method checkTypeDefinition (line 1906) | func (a *ArchitecturalAnalyzer) checkTypeDefinition(typeSpec *ast.Type...
method isValidInternalImport (line 1931) | func (a *ArchitecturalAnalyzer) isValidInternalImport(importPath strin...
method isProviderPackage (line 1974) | func (a *ArchitecturalAnalyzer) isProviderPackage() bool {
method isMainPackage (line 1980) | func (a *ArchitecturalAnalyzer) isMainPackage() bool {
method isTestFile (line 1987) | func (a *ArchitecturalAnalyzer) isTestFile() bool {
method isImportingOtherProvider (line 1991) | func (a *ArchitecturalAnalyzer) isImportingOtherProvider(importPath st...
method extractProviderName (line 2021) | func (a *ArchitecturalAnalyzer) extractProviderName(path, providerType...
method usesOptionsPattern (line 2036) | func (a *ArchitecturalAnalyzer) usesOptionsPattern(call *ast.CallExpr)...
method shouldUseOptionsPattern (line 2054) | func (a *ArchitecturalAnalyzer) shouldUseOptionsPattern(functionName s...
method followsProviderNamingConvention (line 2104) | func (a *ArchitecturalAnalyzer) followsProviderNamingConvention(typeNa...
method isStandardLibraryCall (line 2124) | func (a *ArchitecturalAnalyzer) isStandardLibraryCall(sel *ast.Selecto...
method checkTestHttpPatterns (line 2166) | func (a *ArchitecturalAnalyzer) checkTestHttpPatterns(call *ast.CallEx...
method checkTestFunctionHttprr (line 2197) | func (a *ArchitecturalAnalyzer) checkTestFunctionHttprr(fn *ast.FuncDe...
method isHttpGetCall (line 2226) | func (a *ArchitecturalAnalyzer) isHttpGetCall(call *ast.CallExpr) bool {
method isHttpClientTransportModification (line 2236) | func (a *ArchitecturalAnalyzer) isHttpClientTransportModification(call...
method functionMakesHttpCalls (line 2243) | func (a *ArchitecturalAnalyzer) functionMakesHttpCalls(fn *ast.FuncDec...
method functionUsesHttptest (line 2326) | func (a *ArchitecturalAnalyzer) functionUsesHttptest(fn *ast.FuncDecl)...
method isCallOnTestInstance (line 2350) | func (a *ArchitecturalAnalyzer) isCallOnTestInstance(sel *ast.Selector...
method isVariableCreatedByMockFunction (line 2384) | func (a *ArchitecturalAnalyzer) isVariableCreatedByMockFunction(varNam...
method isVariableDefinedAsTestStruct (line 2425) | func (a *ArchitecturalAnalyzer) isVariableDefinedAsTestStruct(varName ...
method isInPackage (line 2459) | func (a *ArchitecturalAnalyzer) isInPackage(packageName string) bool {
method functionUsesHttprr (line 2464) | func (a *ArchitecturalAnalyzer) functionUsesHttprr(fn *ast.FuncDecl) b...
method checkProviderConstructorUsage (line 2513) | func (a *ArchitecturalAnalyzer) checkProviderConstructorUsage(call *as...
method checkTestProviderConstructors (line 2569) | func (a *ArchitecturalAnalyzer) checkTestProviderConstructors(fn *ast....
method isProviderConstructorCall (line 2634) | func (a *ArchitecturalAnalyzer) isProviderConstructorCall(call *ast.Ca...
method getConstructorName (line 2669) | func (a *ArchitecturalAnalyzer) getConstructorName(call *ast.CallExpr)...
method getCurrentFunction (line 2679) | func (a *ArchitecturalAnalyzer) getCurrentFunction(node ast.Node) *ast...
method functionSkipsHttprr (line 2695) | func (a *ArchitecturalAnalyzer) functionSkipsHttprr(fn *ast.FuncDecl) ...
method functionSkipsHttprrCheck (line 2736) | func (a *ArchitecturalAnalyzer) functionSkipsHttprrCheck(fn *ast.FuncD...
method functionUsesProviderConstructors (line 2811) | func (a *ArchitecturalAnalyzer) functionUsesProviderConstructors(fn *a...
method isAssertOrEqualsCall (line 2831) | func (a *ArchitecturalAnalyzer) isAssertOrEqualsCall(call *ast.CallExp...
method containsHardcodedApiUrl (line 2844) | func (a *ArchitecturalAnalyzer) containsHardcodedApiUrl(call *ast.Call...
FILE: internal/devtools/normalize-recordings/main.go
function main (line 20) | func main() {
function normalizeRecording (line 69) | func normalizeRecording(filename string) error {
function normalizeHTTPRRFile (line 107) | func normalizeHTTPRRFile(content string) string {
function normalizeContent (line 191) | func normalizeContent(content string) string {
function showChanges (line 211) | func showChanges(original, normalized string) {
FILE: internal/devtools/rrtool/main.go
function main (line 14) | func main() {
function checkCmd (line 35) | func checkCmd() {
function listPackagesCmd (line 78) | func listPackagesCmd() {
function findPackagesWithHttprr (line 112) | func findPackagesWithHttprr(rootDir string) ([]string, error) {
function fileImportsHttprr (line 172) | func fileImportsHttprr(filePath string) (bool, error) {
function showUsage (line 190) | func showUsage() {
FILE: internal/httprr/normalization_test.go
function TestNormalizeGoogleAPIClientHeader (line 8) | func TestNormalizeGoogleAPIClientHeader(t *testing.T) {
function TestNormalizeVersionHeader (line 50) | func TestNormalizeVersionHeader(t *testing.T) {
function TestVersionNormalizationConsistency (line 93) | func TestVersionNormalizationConsistency(t *testing.T) {
function TestOpenAIProjectHeaderScrubbing (line 112) | func TestOpenAIProjectHeaderScrubbing(t *testing.T) {
FILE: internal/httprr/rr.go
function init (line 49) | func init() {
type RecordReplay (line 65) | type RecordReplay struct
method ScrubReq (line 89) | func (rr *RecordReplay) ScrubReq(scrubs ...func(req *http.Request) err...
method ScrubResp (line 107) | func (rr *RecordReplay) ScrubResp(scrubs ...func(*bytes.Buffer) error) {
method Recording (line 112) | func (rr *RecordReplay) Recording() bool {
method Replaying (line 117) | func (rr *RecordReplay) Replaying() bool {
method Client (line 294) | func (rr *RecordReplay) Client() *http.Client {
method RoundTrip (line 330) | func (rr *RecordReplay) RoundTrip(req *http.Request) (*http.Response, ...
method reqWire (line 456) | func (rr *RecordReplay) reqWire(req *http.Request) (string, error) {
method respWire (line 526) | func (rr *RecordReplay) respWire(resp *http.Response) (string, error) {
method replayRoundTrip (line 568) | func (rr *RecordReplay) replayRoundTrip(req *http.Request, reqLog stri...
method writeError (line 625) | func (rr *RecordReplay) writeError() error {
method writeLog (line 634) | func (rr *RecordReplay) writeLog(reqWire, respWire string) error {
method Close (line 659) | func (rr *RecordReplay) Close() error {
function Open (line 133) | func Open(file string, rt http.RoundTripper) (*RecordReplay, error) {
function Recording (line 155) | func Recording(file string) (bool, error) {
function getRecordForTesting (line 171) | func getRecordForTesting() string {
function setRecordForTesting (line 179) | func setRecordForTesting(value string) func() {
function create (line 192) | func create(file string, rt http.RoundTripper) (*RecordReplay, error) {
function open (line 217) | func open(file string, rt http.RoundTripper) (*RecordReplay, error) {
type Body (line 301) | type Body struct
method Read (line 307) | func (b *Body) Read(p []byte) (int, error) {
method Close (line 317) | func (b *Body) Close() error {
function CleanFileName (line 674) | func CleanFileName(testName string) string {
function logWriter (line 699) | func logWriter(t *testing.T) io.Writer {
type testWriter (line 704) | type testWriter struct
method Write (line 706) | func (w testWriter) Write(b []byte) (int, error) {
function OpenForEmbeddingTest (line 741) | func OpenForEmbeddingTest(t *testing.T, rt http.RoundTripper) *RecordRep...
function OpenForTest (line 747) | func OpenForTest(t *testing.T, rt http.RoundTripper) *RecordReplay {
function cleanupExistingFiles (line 812) | func cleanupExistingFiles(t *testing.T, baseFilename string) {
function findBestReplayFile (line 826) | func findBestReplayFile(t *testing.T, baseFilename string) string {
function SkipIfNoCredentialsAndRecordingMissing (line 869) | func SkipIfNoCredentialsAndRecordingMissing(t *testing.T, envVars ...str...
function hasRequiredCredentials (line 889) | func hasRequiredCredentials(envVars []string) bool {
function hasExistingRecording (line 899) | func hasExistingRecording(t *testing.T) bool {
function normalizeGoogleAPIClientHeader (line 916) | func normalizeGoogleAPIClientHeader(header string) string {
function normalizeVersionHeader (line 991) | func normalizeVersionHeader(header string) string {
function getDefaultRequestScrubbers (line 1019) | func getDefaultRequestScrubbers() []func(*http.Request) error {
function getDefaultResponseScrubbers (line 1102) | func getDefaultResponseScrubbers() []func(*bytes.Buffer) error {
function conditionalEmbeddingFormatter (line 1140) | func conditionalEmbeddingFormatter() func(*bytes.Buffer) error {
function EmbeddingJSONFormatter (line 1164) | func EmbeddingJSONFormatter() func(*bytes.Buffer) error {
function formatJSONBody (line 1203) | func formatJSONBody(data []byte) []byte {
function formatJSONValue (line 1226) | func formatJSONValue(v interface{}, indent int) string {
FILE: internal/httprr/rr_test.go
function handler (line 19) | func handler(w http.ResponseWriter, r *http.Request) {
function always555 (line 42) | func always555(w http.ResponseWriter, r *http.Request) {
function dropPort (line 46) | func dropPort(r *http.Request) error {
function dropSecretHeader (line 54) | func dropSecretHeader(r *http.Request) error {
function hideSecretBody (line 59) | func hideSecretBody(r *http.Request) error {
function doNothing (line 67) | func doNothing(b *bytes.Buffer) error {
function doRefresh (line 71) | func doRefresh(b *bytes.Buffer) error {
function TestRecordReplay (line 78) | func TestRecordReplay(t *testing.T) {
function TestErrors (line 192) | func TestErrors(t *testing.T) {
type errTransport (line 368) | type errTransport struct
method RoundTrip (line 370) | func (e errTransport) RoundTrip(req *http.Request) (*http.Response, er...
type badRespTransport (line 374) | type badRespTransport struct
method RoundTrip (line 376) | func (badRespTransport) RoundTrip(req *http.Request) (*http.Response, ...
FILE: internal/httprr/rr_unit_test.go
function TestCleanFileName (line 16) | func TestCleanFileName(t *testing.T) {
function TestBodyReadClose (line 84) | func TestBodyReadClose(t *testing.T) {
function TestRecordReplayBasics (line 116) | func TestRecordReplayBasics(t *testing.T) {
function TestScrubReqResp (line 134) | func TestScrubReqResp(t *testing.T) {
function TestRecordingFlag (line 161) | func TestRecordingFlag(t *testing.T) {
function TestWriteError (line 221) | func TestWriteError(t *testing.T) {
function TestClient (line 238) | func TestClient(t *testing.T) {
function TestDefaultRequestScrubbers (line 248) | func TestDefaultRequestScrubbers(t *testing.T) {
function TestDefaultResponseScrubbers (line 277) | func TestDefaultResponseScrubbers(t *testing.T) {
function TestEmbeddingJSONFormatter (line 316) | func TestEmbeddingJSONFormatter(t *testing.T) {
function TestFormatJSONValue (line 335) | func TestFormatJSONValue(t *testing.T) {
function TestFormatJSONBody (line 400) | func TestFormatJSONBody(t *testing.T) {
function TestHasRequiredCredentials (line 445) | func TestHasRequiredCredentials(t *testing.T) {
function TestConstants (line 495) | func TestConstants(t *testing.T) {
function TestTestWriter (line 505) | func TestTestWriter(t *testing.T) {
function TestSetRecordForTesting (line 518) | func TestSetRecordForTesting(t *testing.T) {
function TestRecordReplayClose (line 533) | func TestRecordReplayClose(t *testing.T) {
function TestInternalStructs (line 551) | func TestInternalStructs(t *testing.T) {
FILE: internal/imageutil/download.go
function DownloadImageData (line 14) | func DownloadImageData(url string) (string, []byte, error) {
FILE: internal/imageutil/download_test.go
function requireHttprrRecording (line 14) | func requireHttprrRecording(t *testing.T) *httprr.RecordReplay {
function TestDownloadImageData_Integration (line 31) | func TestDownloadImageData_Integration(t *testing.T) {
function TestDownloadImageData_JPEG (line 52) | func TestDownloadImageData_JPEG(t *testing.T) {
function TestDownloadImageData_InvalidURL_Integration (line 73) | func TestDownloadImageData_InvalidURL_Integration(t *testing.T) {
function TestDownloadImageData_NotFound (line 92) | func TestDownloadImageData_NotFound(t *testing.T) {
function TestDownloadImageData_InvalidMimeType (line 113) | func TestDownloadImageData_InvalidMimeType(t *testing.T) {
FILE: internal/imageutil/download_unit_test.go
function TestDownloadImageData (line 12) | func TestDownloadImageData(t *testing.T) {
function TestDownloadImageData_InvalidURL (line 111) | func TestDownloadImageData_InvalidURL(t *testing.T) {
FILE: internal/maputil/map.go
function ListKeys (line 3) | func ListKeys[T any](m map[string]T) []string {
FILE: internal/maputil/map_test.go
function TestListKeys (line 10) | func TestListKeys(t *testing.T) {
function TestListKeys_TypedMaps (line 72) | func TestListKeys_TypedMaps(t *testing.T) {
FILE: internal/mongodb/client.go
function NewClient (line 11) | func NewClient(ctx context.Context, url string) (*mongo.Client, error) {
FILE: internal/setutil/set.go
function ToSet (line 4) | func ToSet(list []string) map[string]struct{} {
function Difference (line 13) | func Difference(list []string, set map[string]struct{}) []string {
function Intersection (line 24) | func Intersection(list []string, set map[string]struct{}) []string {
FILE: internal/setutil/set_test.go
function TestToSet (line 9) | func TestToSet(t *testing.T) {
function TestDifference (line 63) | func TestDifference(t *testing.T) {
function TestIntersection (line 132) | func TestIntersection(t *testing.T) {
function TestSetOperationsCombined (line 204) | func TestSetOperationsCombined(t *testing.T) {
FILE: internal/sliceutil/slice.go
function MinInt (line 5) | func MinInt(nums []int) int {
FILE: internal/sliceutil/slice_test.go
function TestMinInt (line 7) | func TestMinInt(t *testing.T) {
FILE: internal/testutil/testctr/testctr.go
function EnsureTestEnv (line 50) | func EnsureTestEnv() int {
function SkipIfDockerNotAvailable (line 122) | func SkipIfDockerNotAvailable(t *testing.T) {
FILE: jsonschema/json.go
type DataType (line 9) | type DataType
constant Object (line 12) | Object DataType = "object"
constant Number (line 13) | Number DataType = "number"
constant Integer (line 14) | Integer DataType = "integer"
constant String (line 15) | String DataType = "string"
constant Array (line 16) | Array DataType = "array"
constant Null (line 17) | Null DataType = "null"
constant Boolean (line 18) | Boolean DataType = "boolean"
type Definition (line 23) | type Definition struct
method MarshalJSON (line 39) | func (d Definition) MarshalJSON() ([]byte, error) {
FILE: jsonschema/json_test.go
function TestDefinition_MarshalJSON (line 11) | func TestDefinition_MarshalJSON(t *testing.T) { //nolint:funlen
function structToMap (line 198) | func structToMap(t *testing.T, v any) map[string]any {
FILE: llms/anthropic/anthropicllm.go
constant RoleUser (line 28) | RoleUser = "user"
constant RoleAssistant (line 29) | RoleAssistant = "assistant"
constant RoleSystem (line 30) | RoleSystem = "system"
type LLM (line 33) | type LLM struct
method Call (line 79) | func (o *LLM) Call(ctx context.Context, prompt string, options ...llms...
method GenerateContent (line 84) | func (o *LLM) GenerateContent(ctx context.Context, messages []llms.Mes...
method SupportsReasoning (line 441) | func (o *LLM) SupportsReasoning() bool {
function New (line 45) | func New(opts ...Option) (*LLM, error) {
function newClient (line 56) | func newClient(opts ...Option) (*anthropicclient.Client, error) {
function generateCompletionsContent (line 100) | func generateCompletionsContent(ctx context.Context, o *LLM, messages []...
function generateMessagesContent (line 138) | func generateMessagesContent(ctx context.Context, o *LLM, messages []llm...
function processAnthropicResponse (line 172) | func processAnthropicResponse(result *anthropicclient.MessageResponsePay...
function toolsToTools (line 255) | func toolsToTools(tools []llms.Tool) []anthropicclient.Tool {
function processMessages (line 267) | func processMessages(messages []llms.MessageContent) ([]anthropicclient....
function handleSystemMessage (line 305) | func handleSystemMessage(msg llms.MessageContent) (string, error) {
function handleHumanMessage (line 322) | func handleHumanMessage(msg llms.MessageContent) (anthropicclient.ChatMe...
function handleAIMessage (line 386) | func handleAIMessage(msg llms.MessageContent) (anthropicclient.ChatMessa...
type ToolResult (line 417) | type ToolResult struct
function handleToolMessage (line 423) | func handleToolMessage(msg llms.MessageContent) (anthropicclient.ChatMes...
function supportsReasoningForModel (line 447) | func supportsReasoningForModel(model string) bool {
function extractThinkingOptions (line 479) | func extractThinkingOptions(o *LLM, opts *llms.CallOptions) ([]string, *...
function extractThinkingFromText (line 537) | func extractThinkingFromText(fullText string) (thinkingContent, outputCo...
FILE: llms/anthropic/anthropicllm_option.go
constant tokenEnvVarName (line 8) | tokenEnvVarName = "ANTHROPIC_API_KEY"
constant MaxTokensAnthropicSonnet35 (line 13) | MaxTokensAnthropicSonnet35 = "max-tokens-3-5-sonnet-2024-07-15"
type options (line 15) | type options struct
type Option (line 27) | type Option
function WithToken (line 31) | func WithToken(token string) Option {
function WithModel (line 38) | func WithModel(model string) Option {
function WithBaseURL (line 46) | func WithBaseURL(baseURL string) Option {
function WithHTTPClient (line 54) | func WithHTTPClient(client anthropicclient.Doer) Option {
function WithLegacyTextCompletionsAPI (line 61) | func WithLegacyTextCompletionsAPI() Option {
function WithAnthropicBetaHeader (line 68) | func WithAnthropicBetaHeader(value string) Option {
FILE: llms/anthropic/anthropicllm_test.go
function TestNew (line 10) | func TestNew(t *testing.T) {
function TestProcessMessages (line 63) | func TestProcessMessages(t *testing.T) {
function TestToolsToTools (line 146) | func TestToolsToTools(t *testing.T) {
function TestOptions (line 180) | func TestOptions(t *testing.T) {
function TestCall (line 222) | func TestCall(t *testing.T) {
function TestGenerateMessagesContent_EmptyContent (line 227) | func TestGenerateMessagesContent_EmptyContent(t *testing.T) {
FILE: llms/anthropic/errors.go
type errorMapping (line 10) | type errorMapping struct
function MapError (line 61) | func MapError(err error) error {
FILE: llms/anthropic/internal/anthropicclient/anthropicclient.go
constant DefaultBaseURL (line 16) | DefaultBaseURL = "https://api.anthropic.com/v1"
constant defaultModel (line 18) | defaultModel = "claude-3-5-sonnet-20240620"
type Client (line 25) | type Client struct
method CreateCompletion (line 110) | func (c *Client) CreateCompletion(ctx context.Context, r *CompletionRe...
method CreateMessage (line 150) | func (c *Client) CreateMessage(ctx context.Context, r *MessageRequest)...
method setHeaders (line 171) | func (c *Client) setHeaders(req *http.Request, betaHeaders []string) {
method do (line 189) | func (c *Client) do(ctx context.Context, path string, payloadBytes []b...
method doWithHeaders (line 193) | func (c *Client) doWithHeaders(ctx context.Context, path string, paylo...
method decodeError (line 221) | func (c *Client) decodeError(resp *http.Response) error {
type Option (line 39) | type Option
type Doer (line 42) | type Doer interface
function WithHTTPClient (line 47) | func WithHTTPClient(client Doer) Option {
function WithLegacyTextCompletionsAPI (line 56) | func WithLegacyTextCompletionsAPI(val bool) Option {
function WithAnthropicBetaHeader (line 64) | func WithAnthropicBetaHeader(val string) Option {
function New (line 72) | func New(token string, model string, baseURL string, opts ...Option) (*C...
type CompletionRequest (line 90) | type CompletionRequest struct
type Completion (line 105) | type Completion struct
type MessageRequest (line 129) | type MessageRequest struct
type errorMessage (line 214) | type errorMessage struct
FILE: llms/anthropic/internal/anthropicclient/anthropicclient_test.go
function TestClient_CreateCompletion (line 14) | func TestClient_CreateCompletion(t *testing.T) {
function TestClient_CreateMessage (line 44) | func TestClient_CreateMessage(t *testing.T) {
function TestClient_CreateMessageStream (line 75) | func TestClient_CreateMessageStream(t *testing.T) {
function TestClient_WithAnthropicBetaHeader (line 112) | func TestClient_WithAnthropicBetaHeader(t *testing.T) {
FILE: llms/anthropic/internal/anthropicclient/completions.go
type completionPayload (line 14) | type completionPayload struct
type CompletionResponsePayload (line 26) | type CompletionResponsePayload struct
method setCompletionDefaults (line 34) | func (c *Client) setCompletionDefaults(payload *completionPayload) {
method createCompletion (line 61) | func (c *Client) createCompletion(ctx context.Context, payload *completi...
type CompletionEvent (line 91) | type CompletionEvent struct
function parseStreamingCompletionResponse (line 96) | func parseStreamingCompletionResponse(ctx context.Context, r *http.Respo...
FILE: llms/anthropic/internal/anthropicclient/messages.go
type ChatMessage (line 31) | type ChatMessage struct
type messagePayload (line 36) | type messagePayload struct
type ThinkingConfig (line 55) | type ThinkingConfig struct
type Tool (line 61) | type Tool struct
type CacheControl (line 68) | type CacheControl struct
type Content (line 73) | type Content interface
type TextContent (line 77) | type TextContent struct
method GetType (line 83) | func (tc TextContent) GetType() string {
type ImageContent (line 87) | type ImageContent struct
method GetType (line 93) | func (ic ImageContent) GetType() string {
type ImageSource (line 97) | type ImageSource struct
type ToolUseContent (line 103) | type ToolUseContent struct
method GetType (line 113) | func (tuc ToolUseContent) GetType() string {
type ToolResultContent (line 117) | type ToolResultContent struct
method GetType (line 124) | func (trc ToolResultContent) GetType() string {
type ThinkingContent (line 129) | type ThinkingContent struct
method GetType (line 135) | func (tc ThinkingContent) GetType() string {
type MessageResponsePayload (line 139) | type MessageResponsePayload struct
method UnmarshalJSON (line 155) | func (m *MessageResponsePayload) UnmarshalJSON(data []byte) error {
method setMessageDefaults (line 202) | func (c *Client) setMessageDefaults(payload *messagePayload) {
method createMessage (line 228) | func (c *Client) createMessage(ctx context.Context, payload *messagePayl...
type MessageEvent (line 258) | type MessageEvent struct
function parseStreamingMessageResponse (line 263) | func parseStreamingMessageResponse(ctx context.Context, r *http.Response...
function parseStreamEvent (line 302) | func parseStreamEvent(data string) (map[string]interface{}, error) {
function processStreamEvent (line 308) | func processStreamEvent(ctx context.Context, event map[string]interface{...
function handleMessageStartEvent (line 336) | func handleMessageStartEvent(event map[string]interface{}, response Mess...
function handleContentBlockStartEvent (line 369) | func handleContentBlockStartEvent(event map[string]interface{}, response...
function handleContentBlockDeltaEvent (line 418) | func handleContentBlockDeltaEvent(ctx context.Context, event map[string]...
function handleTextDelta (line 451) | func handleTextDelta(ctx context.Context, delta map[string]interface{}, ...
function handleJSONDelta (line 474) | func handleJSONDelta(delta map[string]interface{}, response MessageRespo...
function handleThinkingDelta (line 489) | func handleThinkingDelta(ctx context.Context, delta map[string]interface...
function handleContentBlockStop (line 513) | func handleContentBlockStop(event map[string]interface{}, response Messa...
function handleMessageDeltaEvent (line 537) | func handleMessageDeltaEvent(event map[string]interface{}, response Mess...
function getString (line 566) | func getString(m map[string]interface{}, key string) string {
function getFloat64 (line 574) | func getFloat64(m map[string]interface{}, key string) (float64, error) {
FILE: llms/anthropic/internal/anthropicclient/messages_test.go
function Test_parseStreamingMessageResponse_withEmptyInput (line 12) | func Test_parseStreamingMessageResponse_withEmptyInput(t *testing.T) {
function Test_parseStreamingMessageResponse_withInputJSONDeltas (line 41) | func Test_parseStreamingMessageResponse_withInputJSONDeltas(t *testing.T) {
function createSSEResponse (line 74) | func createSSEResponse(data string) *http.Response {
constant SSEDataWithEmptyInput (line 85) | SSEDataWithEmptyInput = `event: message_start
constant SSEDataWithInputJSONDeltas (line 121) | SSEDataWithInputJSONDeltas = `event: message_start
FILE: llms/anthropic/llmtest_test.go
function TestLLM (line 10) | func TestLLM(t *testing.T) {
FILE: llms/anthropic/options.go
function WithPromptCaching (line 18) | func WithPromptCaching() llms.CallOption {
function WithExtendedOutput (line 37) | func WithExtendedOutput() llms.CallOption {
function WithInterleavedThinking (line 61) | func WithInterleavedThinking() llms.CallOption {
function WithBetaHeader (line 83) | func WithBetaHeader(header string) llms.CallOption {
function EphemeralCache (line 98) | func EphemeralCache() *llms.CacheControl {
function EphemeralCacheOneHour (line 106) | func EphemeralCacheOneHour() *llms.CacheControl {
FILE: llms/anthropic/options_test.go
function TestEphemeralCache (line 11) | func TestEphemeralCache(t *testing.T) {
function TestEphemeralCacheOneHour (line 23) | func TestEphemeralCacheOneHour(t *testing.T) {
function TestWithPromptCaching (line 35) | func TestWithPromptCaching(t *testing.T) {
function TestWithExtendedOutput (line 55) | func TestWithExtendedOutput(t *testing.T) {
function TestWithInterleavedThinking (line 75) | func TestWithInterleavedThinking(t *testing.T) {
function TestWithBetaHeader (line 95) | func TestWithBetaHeader(t *testing.T) {
function TestMultipleBetaHeaders (line 115) | func TestMultipleBetaHeaders(t *testing.T) {
FILE: llms/anthropic/prompt_caching_test.go
function TestAnthropicPromptCaching (line 11) | func TestAnthropicPromptCaching(t *testing.T) {
function TestAnthropicCacheControlInMessages (line 102) | func TestAnthropicCacheControlInMessages(t *testing.T) {
function TestAnthropicBetaHeaders (line 142) | func TestAnthropicBetaHeaders(t *testing.T) {
FILE: llms/bedrock/bedrock_tool_integration_test.go
function TestBedrockAnthropicToolCalling (line 16) | func TestBedrockAnthropicToolCalling(t *testing.T) { //nolint:funlen
function hasAWSCredentials (line 181) | func hasAWSCredentials() bool {
FILE: llms/bedrock/bedrockllm.go
constant defaultModel (line 14) | defaultModel = ModelAmazonTitanTextLiteV1
type LLM (line 17) | type LLM struct
method Call (line 64) | func (l *LLM) Call(ctx context.Context, prompt string, options ...llms...
method GenerateContent (line 69) | func (l *LLM) GenerateContent(ctx context.Context, messages []llms.Mes...
function New (line 25) | func New(opts ...Option) (*LLM, error) {
function NewWithContext (line 30) | func NewWithContext(ctx context.Context, opts ...Option) (*LLM, error) {
function newClient (line 43) | func newClient(ctx context.Context, opts ...Option) (*options, *bedrockc...
function processMessages (line 101) | func processMessages(messages []llms.MessageContent) ([]bedrockclient.Me...
FILE: llms/bedrock/bedrockllm_option.go
type Option (line 9) | type Option
type options (line 11) | type options struct
function WithModel (line 22) | func WithModel(modelID string) Option {
function WithModelProvider (line 32) | func WithModelProvider(modelProvider string) Option {
function WithClient (line 45) | func WithClient(client *bedrockruntime.Client) Option {
function WithCallback (line 52) | func WithCallback(callbackHandler callbacks.Handler) Option {
FILE: llms/bedrock/bedrockllm_test.go
function hasExistingRecording (line 20) | func hasExistingRecording(t *testing.T) bool {
function setUpTestWithTransport (line 28) | func setUpTestWithTransport(transport http.RoundTripper) (*bedrockruntim...
function TestAmazonOutput (line 43) | func TestAmazonOutput(t *testing.T) {
function TestAmazonNova (line 125) | func TestAmazonNova(t *testing.T) {
function TestAnthropicNovaImage (line 192) | func TestAnthropicNovaImage(t *testing.T) {
function TestBedrockWithTools (line 265) | func TestBedrockWithTools(t *testing.T) { //nolint:funlen
function TestBedrockToolCallMultipleIterations (line 391) | func TestBedrockToolCallMultipleIterations(t *testing.T) { //nolint:funlen
FILE: llms/bedrock/bedrockllm_unit_test.go
function TestNew (line 12) | func TestNew(t *testing.T) {
function TestNewWithContext (line 59) | func TestNewWithContext(t *testing.T) {
function TestProcessMessages (line 70) | func TestProcessMessages(t *testing.T) {
function TestOptions (line 142) | func TestOptions(t *testing.T) {
function TestModelConstants (line 170) | func TestModelConstants(t *testing.T) {
function containsProvider (line 193) | func containsProvider(model string) bool {
type testCallbackHandler (line 204) | type testCallbackHandler struct
method HandleLLMGenerateContentStart (line 206) | func (h *testCallbackHandler) HandleLLMGenerateContentStart(ctx contex...
method HandleLLMGenerateContentEnd (line 208) | func (h *testCallbackHandler) HandleLLMGenerateContentEnd(ctx context....
method HandleLLMError (line 210) | func (h *testCallbackHandler) HandleLLMError(ctx context.Context, err ...
method HandleText (line 211) | func (h *testCallbackHandler) HandleText(ctx context.Context, text str...
method HandleLLMStart (line 212) | func (h *testCallbackHandler) HandleLLMStart(ctx context.Context, prom...
method HandleChainStart (line 213) | func (h *testCallbackHandler) HandleChainStart(ctx context.Context, in...
method HandleChainEnd (line 214) | func (h *testCallbackHandler) HandleChainEnd(ctx context.Context, outp...
method HandleChainError (line 215) | func (h *testCallbackHandler) HandleChainError(ctx context.Context, er...
method HandleToolStart (line 216) | func (h *testCallbackHandler) HandleToolStart(ctx context.Context, inp...
method HandleToolEnd (line 217) | func (h *testCallbackHandler) HandleToolEnd(ctx context.Context, outpu...
method HandleToolError (line 218) | func (h *testCallbackHandler) HandleToolError(ctx context.Context, err...
method HandleAgentAction (line 219) | func (h *testCallbackHandler) HandleAgentAction(ctx context.Context, a...
method HandleAgentFinish (line 220) | func (h *testCallbackHandler) HandleAgentFinish(ctx context.Context, f...
method HandleRetrieverStart (line 221) | func (h *testCallbackHandler) HandleRetrieverStart(ctx context.Context...
method HandleRetrieverEnd (line 222) | func (h *testCallbackHandler) HandleRetrieverEnd(ctx context.Context, ...
method HandleStreamingFunc (line 224) | func (h *testCallbackHandler) HandleStreamingFunc(ctx context.Context,...
FILE: llms/bedrock/errors.go
type errorMapping (line 10) | type errorMapping struct
function MapError (line 61) | func MapError(err error) error {
FILE: llms/bedrock/internal/bedrockclient/bedrockclient.go
type Client (line 13) | type Client struct
method CreateCompletion (line 74) | func (c *Client) CreateCompletion(ctx context.Context,
type Message (line 22) | type Message struct
function getProvider (line 37) | func getProvider(modelID string) string {
function NewClient (line 66) | func NewClient(client *bedrockruntime.Client) *Client {
function processInputMessagesGeneric (line 103) | func processInputMessagesGeneric(messages []Message) string {
function getMaxTokens (line 124) | func getMaxTokens(maxTokens, defaultValue int) int {
FILE: llms/bedrock/internal/bedrockclient/bedrockclient_integration_test.go
type mockBedrockClient (line 20) | type mockBedrockClient struct
method InvokeModel (line 25) | func (m *mockBedrockClient) InvokeModel(ctx context.Context, params *b...
method InvokeModelWithResponseStream (line 32) | func (m *mockBedrockClient) InvokeModelWithResponseStream(ctx context....
type mockEventStream (line 40) | type mockEventStream struct
method Events (line 46) | func (m *mockEventStream) Events() <-chan types.ResponseStream {
method Close (line 50) | func (m *mockEventStream) Close() error {
method Err (line 58) | func (m *mockEventStream) Err() error {
function TestClient_CreateCompletion (line 63) | func TestClient_CreateCompletion(t *testing.T) {
function testCreateCompletionWithMock (line 379) | func testCreateCompletionWithMock(ctx context.Context, client *mockBedro...
function TestClient_CreateCompletion_Streaming (line 398) | func TestClient_CreateCompletion_Streaming(t *testing.T) {
function TestClient_CreateCompletion_StreamingErrors (line 530) | func TestClient_CreateCompletion_StreamingErrors(t *testing.T) {
function TestClient_CreateCompletion_EdgeCases (line 592) | func TestClient_CreateCompletion_EdgeCases(t *testing.T) {
function TestNewClient (line 720) | func TestNewClient(t *testing.T) {
function TestClient_CreateCompletion_StreamingCancellation (line 729) | func TestClient_CreateCompletion_StreamingCancellation(t *testing.T) {
function testCreateAi21CompletionWithMock (line 799) | func testCreateAi21CompletionWithMock(ctx context.Context, client *mockB...
function testCreateAmazonCompletionWithMock (line 864) | func testCreateAmazonCompletionWithMock(ctx context.Context, client *moc...
function testCreateAnthropicCompletionWithMock (line 920) | func testCreateAnthropicCompletionWithMock(ctx context.Context, client *...
function testCreateCohereCompletionWithMock (line 988) | func testCreateCohereCompletionWithMock(ctx context.Context, client *moc...
function testCreateMetaCompletionWithMock (line 1040) | func testCreateMetaCompletionWithMock(ctx context.Context, client *mockB...
function testParseStreamingCompletionResponse (line 1089) | func testParseStreamingCompletionResponse(ctx context.Context, stream *m...
FILE: llms/bedrock/internal/bedrockclient/bedrockclient_nova_test.go
function TestGetProvider_NovaModels (line 7) | func TestGetProvider_NovaModels(t *testing.T) {
function TestGetProvider_EdgeCases (line 87) | func TestGetProvider_EdgeCases(t *testing.T) {
FILE: llms/bedrock/internal/bedrockclient/bedrockclient_test.go
function TestGetProvider (line 15) | func TestGetProvider(t *testing.T) {
function TestProcessInputMessagesGeneric (line 61) | func TestProcessInputMessagesGeneric(t *testing.T) {
function TestGetMaxTokens (line 114) | func TestGetMaxTokens(t *testing.T) {
function TestCreateCompletion_UnsupportedProvider (line 149) | func TestCreateCompletion_UnsupportedProvider(t *testing.T) {
function TestCreateAi21Completion_RequestStructure (line 167) | func TestCreateAi21Completion_RequestStructure(t *testing.T) {
function TestCreateAmazonCompletion_RequestStructure (line 218) | func TestCreateAmazonCompletion_RequestStructure(t *testing.T) {
function TestProcessInputMessagesAnthropic (line 256) | func TestProcessInputMessagesAnthropic(t *testing.T) {
function TestGetAnthropicRole (line 347) | func TestGetAnthropicRole(t *testing.T) {
function TestGetAnthropicInputContent (line 400) | func TestGetAnthropicInputContent(t *testing.T) {
function TestCreateCohereCompletion_RequestStructure (line 445) | func TestCreateCohereCompletion_RequestStructure(t *testing.T) {
function TestCreateMetaCompletion_RequestStructure (line 486) | func TestCreateMetaCompletion_RequestStructure(t *testing.T) {
function TestAi21ResponseParsing (line 518) | func TestAi21ResponseParsing(t *testing.T) {
function TestAmazonResponseParsing (line 580) | func TestAmazonResponseParsing(t *testing.T) {
function TestCohereResponseParsing (line 610) | func TestCohereResponseParsing(t *testing.T) {
function TestMetaResponseParsing (line 642) | func TestMetaResponseParsing(t *testing.T) {
function TestAnthropicResponseParsing (line 663) | func TestAnthropicResponseParsing(t *testing.T) {
function TestEmptyResponses (line 702) | func TestEmptyResponses(t *testing.T) {
function TestAnthropicStreamingResponseChunk (line 731) | func TestAnthropicStreamingResponseChunk(t *testing.T) {
function TestBedrockRequestStructures (line 829) | func TestBedrockRequestStructures(t *testing.T) {
FILE: llms/bedrock/internal/bedrockclient/provider_ai21.go
type ai21TextGenerationInput (line 13) | type ai21TextGenerationInput struct
type ai21TextGenerationOutput (line 41) | type ai21TextGenerationOutput struct
constant Ai21CompletionReasonLength (line 73) | Ai21CompletionReasonLength = "length"
constant Ai21CompletionReasonStop (line 74) | Ai21CompletionReasonStop = "stop"
constant Ai21CompletionReasonEndOfText (line 75) | Ai21CompletionReasonEndOfText = "endoftext"
function createAi21Completion (line 78) | func createAi21Completion(ctx context.Context, client *bedrockruntime.Cl...
FILE: llms/bedrock/internal/bedrockclient/provider_amazon.go
type amazonTextGenerationConfigInput (line 16) | type amazonTextGenerationConfigInput struct
type amazonTextGenerationInput (line 29) | type amazonTextGenerationInput struct
type amazonTextGenerationOutput (line 37) | type amazonTextGenerationOutput struct
constant AmazonCompletionReasonFinish (line 54) | AmazonCompletionReasonFinish = "FINISH"
constant AmazonCompletionReasonMaxTokens (line 55) | AmazonCompletionReasonMaxTokens = "LENGTH"
constant AmazonCompletionReasonContentFiltered (line 56) | AmazonCompletionReasonContentFiltered = "CONTENT_FILTERED"
function createAmazonCompletion (line 59) | func createAmazonCompletion(ctx context.Context,
FILE: llms/bedrock/internal/bedrockclient/provider_anthropic.go
type anthropicBinGenerationInputSource (line 21) | type anthropicBinGenerationInputSource struct
type anthropicTextGenerationInputContent (line 34) | type anthropicTextGenerationInputContent struct
type anthropicTextGenerationInputMessage (line 51) | type anthropicTextGenerationInputMessage struct
type anthropicTextGenerationInput (line 61) | type anthropicTextGenerationInput struct
type anthropicTextGenerationOutput (line 87) | type anthropicTextGenerationOutput struct
type anthropicContentBlock (line 109) | type anthropicContentBlock struct
constant AnthropicCompletionReasonEndTurn (line 120) | AnthropicCompletionReasonEndTurn = "end_turn"
constant AnthropicCompletionReasonMaxTokens (line 121) | AnthropicCompletionReasonMaxTokens = "max_tokens"
constant AnthropicCompletionReasonStopSequence (line 122) | AnthropicCompletionReasonStopSequence = "stop_sequence"
constant AnthropicLatestVersion (line 127) | AnthropicLatestVersion = "bedrock-2023-05-31"
constant AnthropicSystem (line 132) | AnthropicSystem = "system"
constant AnthropicRoleUser (line 133) | AnthropicRoleUser = "user"
constant AnthropicRoleAssistant (line 134) | AnthropicRoleAssistant = "assistant"
constant AnthropicMessageTypeText (line 139) | AnthropicMessageTypeText = "text"
constant AnthropicMessageTypeImage (line 140) | AnthropicMessageTypeImage = "image"
constant AnthropicMessageTypeToolUse (line 141) | AnthropicMessageTypeToolUse = "tool_use"
constant AnthropicMessageTypeToolResult (line 142) | AnthropicMessageTypeToolResult = "tool_result"
function createAnthropicCompletion (line 145) | func createAnthropicCompletion(ctx context.Context,
type streamingCompletionResponseChunk (line 266) | type streamingCompletionResponseChunk struct
function parseStreamingCompletionResponse (line 299) | func parseStreamingCompletionResponse(ctx context.Context, client *bedro...
function processInputMessagesAnthropic (line 348) | func processInputMessagesAnthropic(messages []Message) ([]*anthropicText...
function getAnthropicRole (line 399) | func getAnthropicRole(role llms.ChatMessageType) (string, error) {
function getAnthropicInputContent (line 418) | func getAnthropicInputContent(message Message) anthropicTextGenerationIn...
FILE: llms/bedrock/internal/bedrockclient/provider_cohere.go
type cohereTextGenerationInput (line 16) | type cohereTextGenerationInput struct
constant CohereCompletionReasonComplete (line 38) | CohereCompletionReasonComplete = "COMPLETE"
constant CohereCompletionReasonMaxTokens (line 39) | CohereCompletionReasonMaxTokens = "MAX_TOKENS"
constant CohereCompletionReasonError (line 40) | CohereCompletionReasonError = "ERROR"
constant CohereCompletionReasonErrorToxic (line 41) | CohereCompletionReasonErrorToxic = "ERROR_TOXIC"
type cohereTextGenerationOutput (line 45) | type cohereTextGenerationOutput struct
type cohereTextGenerationOutputGeneration (line 53) | type cohereTextGenerationOutputGeneration struct
function createCohereCompletion (line 64) | func createCohereCompletion(ctx context.Context,
FILE: llms/bedrock/internal/bedrockclient/provider_meta.go
type metaTextGenerationInput (line 15) | type metaTextGenerationInput struct
type metaTextGenerationOutput (line 29) | type metaTextGenerationOutput struct
constant MetaCompletionReasonStop (line 43) | MetaCompletionReasonStop = "stop"
constant MetaCompletionReasonLength (line 44) | MetaCompletionReasonLength = "length"
function createMetaCompletion (line 47) | func createMetaCompletion(ctx context.Context,
FILE: llms/bedrock/internal/bedrockclient/provider_nova.go
type novaBinGenerationInputSource (line 21) | type novaBinGenerationInputSource struct
type novaImageInput (line 27) | type novaImageInput struct
type novaTextGenerationInputContent (line 37) | type novaTextGenerationInputContent struct
type novaTextGenerationInputMessage (line 45) | type novaTextGenerationInputMessage struct
type novaSystemPrompt (line 56) | type novaSystemPrompt struct
type novaInferenceConfigInput (line 61) | type novaInferenceConfigInput struct
type novaTextGenerationInput (line 74) | type novaTextGenerationInput struct
type novaTextGenerationOutput (line 84) | type novaTextGenerationOutput struct
constant NovaCompletionReasonEndTurn (line 105) | NovaCompletionReasonEndTurn = "end_turn"
constant NovaCompletionReasonStopSequence (line 106) | NovaCompletionReasonStopSequence = "stop_sequence"
constant NovaCompletionReasonMaxTokens (line 107) | NovaCompletionReasonMaxTokens = "max_tokens"
constant NovaCompletionReasonContentFiltered (line 108) | NovaCompletionReasonContentFiltered = "content_filtered"
constant NovaSystem (line 113) | NovaSystem = "system"
constant NovaRoleUser (line 114) | NovaRoleUser = "user"
constant NovaRoleAssistant (line 115) | NovaRoleAssistant = "assistant"
constant NovaMessageTypeText (line 120) | NovaMessageTypeText = "text"
constant NovaMessageTypeImage (line 121) | NovaMessageTypeImage = "image"
function novaInputToJSON (line 124) | func novaInputToJSON(inputContents []*novaTextGenerationInputMessage, sy...
function parseNovaResponseBody (line 138) | func parseNovaResponseBody(body []byte) (*novaTextGenerationOutput, erro...
function createNovaCompletion (line 144) | func createNovaCompletion(ctx context.Context,
function processInputMessagesNova (line 207) | func processInputMessagesNova(messages []Message) ([]*novaTextGeneration...
function getNovaRole (line 255) | func getNovaRole(role llms.ChatMessageType) (string, error) {
function getNovaInputContent (line 274) | func getNovaInputContent(message Message) novaTextGenerationInputContent {
function mimeTypeToFormat (line 292) | func mimeTypeToFormat(mimeType string) string {
FILE: llms/bedrock/internal/bedrockclient/tool_call_test.go
function TestAnthropicToolCallSupport (line 11) | func TestAnthropicToolCallSupport(t *testing.T) {
FILE: llms/bedrock/internal/bedrockclient/tools.go
type BedrockTool (line 11) | type BedrockTool struct
type BedrockToolChoice (line 18) | type BedrockToolChoice struct
type BedrockToolCall (line 24) | type BedrockToolCall struct
function convertToolsToBedrockTools (line 32) | func convertToolsToBedrockTools(tools []llms.Tool) ([]BedrockTool, error) {
function convertToolChoiceToBedrockToolChoice (line 52) | func convertToolChoiceToBedrockToolChoice(toolChoice interface{}) (*Bedr...
function convertBedrockToolCallToLLMToolCall (line 85) | func convertBedrockToolCallToLLMToolCall(bedrockCall BedrockToolCall) (l...
FILE: llms/bedrock/llmtest_test.go
function TestLLM (line 10) | func TestLLM(t *testing.T) {
FILE: llms/bedrock/models_list.go
constant ModelAi21J2UltraV1 (line 13) | ModelAi21J2UltraV1 = "ai21.j2-ultra-v1"
constant ModelAi21J2MidV1 (line 24) | ModelAi21J2MidV1 = "ai21.j2-mid-v1"
constant ModelAmazonTitanTextLiteV1 (line 31) | ModelAmazonTitanTextLiteV1 = "amazon.titan-text-lite-v1"
constant ModelAmazonTitanTextExpressV1 (line 40) | ModelAmazonTitanTextExpressV1 = "amazon.titan-text-express-v1"
constant ModelAmazonNovaMicroV1 (line 49) | ModelAmazonNovaMicroV1 = "us.amazon.nova-micro-v1:0"
constant ModelAmazonNovaLiteV1 (line 59) | ModelAmazonNovaLiteV1 = "us.amazon.nova-lite-v1:0"
constant ModelAmazonNovaProV1 (line 73) | ModelAmazonNovaProV1 = "us.amazon.nova-pro-v1:0"
constant ModelAnthropicClaudeV3Sonnet (line 84) | ModelAnthropicClaudeV3Sonnet = "anthropic.claude-3-sonnet-20240229-v1:0"
constant ModelAnthropicClaudeV3Haiku (line 93) | ModelAnthropicClaudeV3Haiku = "anthropic.claude-3-haiku-20240307-v1:0"
constant ModelAnthropicClaudeV21 (line 100) | ModelAnthropicClaudeV21 = "anthropic.claude-v2:1"
constant ModelAnthropicClaudeV2 (line 107) | ModelAnthropicClaudeV2 = "anthropic.claude-v2"
constant ModelAnthropicClaudeInstantV1 (line 114) | ModelAnthropicClaudeInstantV1 = "anthropic.claude-instant-v1"
constant ModelCohereCommandTextV14 (line 121) | ModelCohereCommandTextV14 = "cohere.command-text-v14"
constant ModelCohereCommandLightTextV14 (line 128) | ModelCohereCommandLightTextV14 = "cohere.command-light-text-v14"
constant ModelMetaLlama213bChatV1 (line 137) | ModelMetaLlama213bChatV1 = "meta.llama2-13b-chat-v1"
constant ModelMetaLlama270bChatV1 (line 146) | ModelMetaLlama270bChatV1 = "meta.llama2-70b-chat-v1"
constant ModelMetaLlama38bInstructV1 (line 155) | ModelMetaLlama38bInstructV1 = "meta.llama3-8b-instruct-v1:0"
constant ModelMetaLlama370bInstructV1 (line 164) | ModelMetaLlama370bInstructV1 = "meta.llama3-70b-instruct-v1:0"
FILE: llms/bedrock/tool_call_test.go
function TestToolCallProcessing (line 10) | func TestToolCallProcessing(t *testing.T) {
FILE: llms/cache/cache.go
type Backend (line 13) | type Backend interface
type Cacher (line 21) | type Cacher struct
method Call (line 45) | func (c *Cacher) Call(ctx context.Context, prompt string, options ...l...
method GenerateContent (line 52) | func (c *Cacher) GenerateContent(ctx context.Context, messages []llms....
function New (line 31) | func New(llm llms.Model, backend Backend) *Cacher {
function hashKeyForCache (line 86) | func hashKeyForCache(messages []llms.MessageContent, opts llms.CallOptio...
FILE: llms/cache/cache_test.go
function TestCache_hashKeyForCache (line 11) | func TestCache_hashKeyForCache(t *testing.T) {
function TestCache_Call (line 66) | func TestCache_Call(t *testing.T) {
function TestCache_Call_Streaming (line 122) | func TestCache_Call_Streaming(t *testing.T) {
FILE: llms/cache/inmemory/inmemory.go
type InMemory (line 11) | type InMemory struct
method Get (line 32) | func (im *InMemory) Get(_ context.Context, key string) *llms.ContentRe...
method Put (line 41) | func (im *InMemory) Put(_ context.Context, key string, value *llms.Con...
function New (line 19) | func New(ctx context.Context, opts ...Option) (*InMemory, error) {
FILE: llms/cache/inmemory/inmemory_test.go
function TestInMemory (line 14) | func TestInMemory(t *testing.T) {
FILE: llms/cache/inmemory/options.go
type Option (line 11) | type Option
type Options (line 14) | type Options struct
function WithCacheOptions (line 22) | func WithCacheOptions(opts ...cache.Option[string, *llms.ContentResponse...
function WithItemOptions (line 34) | func WithItemOptions(opts ...cache.ItemOption) Option {
function WithExpiration (line 44) | func WithExpiration(expiration time.Duration) Option {
function applyOptions (line 52) | func applyOptions(opts ...Option) (*Options, error) {
FILE: llms/cache/mocks_test.go
function newMockLLM (line 11) | func newMockLLM(response *llms.ContentResponse, err error) *mockLLM {
type mockLLM (line 20) | type mockLLM struct
method Call (line 26) | func (m *mockLLM) Call(ctx context.Context, prompt string, options ......
method GenerateContent (line 30) | func (m *mockLLM) GenerateContent(ctx context.Context, _ []llms.Messag...
function newMockCache (line 49) | func newMockCache() *mockCache {
type mockCache (line 58) | type mockCache struct
method Get (line 64) | func (m *mockCache) Get(_ context.Context, key string) *llms.ContentRe...
method Put (line 71) | func (m *mockCache) Put(_ context.Context, key string, response *llms....
FILE: llms/chat_messages.go
type ChatMessageType (line 12) | type ChatMessageType
constant ChatMessageTypeAI (line 20) | ChatMessageTypeAI ChatMessageType = "ai"
constant ChatMessageTypeHuman (line 22) | ChatMessageTypeHuman ChatMessageType = "human"
constant ChatMessageTypeSystem (line 24) | ChatMessageTypeSystem ChatMessageType = "system"
constant ChatMessageTypeGeneric (line 26) | ChatMessageTypeGeneric ChatMessageType = "generic"
constant ChatMessageTypeFunction (line 28) | ChatMessageTypeFunction ChatMessageType = "function"
constant ChatMessageTypeTool (line 30) | ChatMessageTypeTool ChatMessageType = "tool"
type ChatMessage (line 34) | type ChatMessage interface
type Named (line 42) | type Named interface
type AIChatMessage (line 57) | type AIChatMessage struct
method GetType (line 71) | func (m AIChatMessage) GetType() ChatMessageType { return ChatMe...
method GetContent (line 72) | func (m AIChatMessage) GetContent() string { return m.Cont...
method GetFunctionCall (line 73) | func (m AIChatMessage) GetFunctionCall() *FunctionCall { return m.Func...
type HumanChatMessage (line 76) | type HumanChatMessage struct
method GetType (line 80) | func (m HumanChatMessage) GetType() ChatMessageType { return ChatMessa...
method GetContent (line 81) | func (m HumanChatMessage) GetContent() string { return m.Content }
type SystemChatMessage (line 84) | type SystemChatMessage struct
method GetType (line 88) | func (m SystemChatMessage) GetType() ChatMessageType { return ChatMess...
method GetContent (line 89) | func (m SystemChatMessage) GetContent() string { return m.Content }
type GenericChatMessage (line 92) | type GenericChatMessage struct
method GetType (line 98) | func (m GenericChatMessage) GetType() ChatMessageType { return ChatMes...
method GetContent (line 99) | func (m GenericChatMessage) GetContent() string { return m.Conte...
method GetName (line 100) | func (m GenericChatMessage) GetName() string { return m.Name }
type FunctionChatMessage (line 104) | type FunctionChatMessage struct
method GetType (line 111) | func (m FunctionChatMessage) GetType() ChatMessageType { return ChatMe...
method GetContent (line 112) | func (m FunctionChatMessage) GetContent() string { return m.Cont...
method GetName (line 113) | func (m FunctionChatMessage) GetName() string { return m.Name }
type ToolChatMessage (line 116) | type ToolChatMessage struct
method GetType (line 123) | func (m ToolChatMessage) GetType() ChatMessageType { return ChatMessag...
method GetContent (line 124) | func (m ToolChatMessage) GetContent() string { return m.Content }
method GetID (line 125) | func (m ToolChatMessage) GetID() string { return m.ID }
function GetBufferString (line 128) | func GetBufferString(messages []ChatMessage, humanPrefix string, aiPrefi...
function getMessageRole (line 148) | func getMessageRole(m ChatMessage, humanPrefix, aiPrefix string) (string...
type ChatMessageModelData (line 173) | type ChatMessageModelData struct
type ChatMessageModel (line 178) | type ChatMessageModel struct
method ToChatMessage (line 183) | func (c ChatMessageModel) ToChatMessage() ChatMessage {
function ConvertChatMessageToModel (line 196) | func ConvertChatMessageToModel(m ChatMessage) ChatMessageModel {
FILE: llms/chat_messages_test.go
function TestGetBufferString (line 9) | func TestGetBufferString(t *testing.T) {
type unsupportedChatMessage (line 67) | type unsupportedChatMessage struct
method GetType (line 69) | func (m unsupportedChatMessage) GetType() llms.ChatMessageType { retur...
method GetContent (line 70) | func (m unsupportedChatMessage) GetContent() string { retur...
FILE: llms/cloudflare/cloudflarellm.go
type LLM (line 19) | type LLM struct
method Call (line 56) | func (o *LLM) Call(ctx context.Context, prompt string, options ...llms...
method GenerateContent (line 61) | func (o *LLM) GenerateContent(ctx context.Context, messages []llms.Mes...
method CreateEmbedding (line 147) | func (o *LLM) CreateEmbedding(ctx context.Context, inputTexts []string...
function New (line 28) | func New(opts ...Option) (*LLM, error) {
function typeToRole (line 166) | func typeToRole(typ llms.ChatMessageType) cloudflareclient.Role {
FILE: llms/cloudflare/cloudflarellm_test.go
function TestNew (line 16) | func TestNew(t *testing.T) {
function TestNewWithServerURL (line 77) | func TestNewWithServerURL(t *testing.T) {
function TestTypeToRole (line 94) | func TestTypeToRole(t *testing.T) {
function TestGenerateContentErrors (line 147) | func TestGenerateContentErrors(t *testing.T) {
function TestCall (line 214) | func TestCall(t *testing.T) {
function TestCreateEmbedding (line 249) | func TestCreateEmbedding(t *testing.T) {
function TestGenerateContentWithSystemPrompt (line 325) | func TestGenerateContentWithSystemPrompt(t *testing.T) {
function TestGenerateContentWithErrors (line 369) | func TestGenerateContentWithErrors(t *testing.T) {
FILE: llms/cloudflare/internal/cloudflareclient/api.go
method CreateEmbedding (line 15) | func (c *Client) CreateEmbedding(ctx context.Context, texts *CreateEmbed...
constant maxBufferSize (line 53) | maxBufferSize = 512 * 1000
method GenerateContent (line 56) | func (c *Client) GenerateContent(ctx context.Context, request *GenerateC...
method Summarize (line 143) | func (c *Client) Summarize(ctx context.Context, inputText string, maxLen...
FILE: llms/cloudflare/internal/cloudflareclient/api_test.go
function TestClient_GenerateContent (line 12) | func TestClient_GenerateContent(t *testing.T) {
FILE: llms/cloudflare/internal/cloudflareclient/client.go
type httpClient (line 8) | type httpClient interface
type Client (line 12) | type Client struct
function NewClient (line 23) | func NewClient(client httpClient, accountID, baseURL, token, modelName, ...
FILE: llms/cloudflare/internal/cloudflareclient/cloudflareclient_test.go
constant testBaseURL (line 15) | testBaseURL = "https://api.cloudflare.com/client/v4/accounts"
function requireCloudflareCredentialsOrHTTPRR (line 17) | func requireCloudflareCredentialsOrHTTPRR(t *testing.T) *httprr.RecordRe...
function TestClient_GenerateContentWithHTTPRR (line 38) | func TestClient_GenerateContentWithHTTPRR(t *testing.T) {
function TestClient_GenerateContentStream (line 75) | func TestClient_GenerateContentStream(t *testing.T) {
function TestClient_CreateEmbedding (line 116) | func TestClient_CreateEmbedding(t *testing.T) {
FILE: llms/cloudflare/internal/cloudflareclient/model.go
type GenerateContentRequest (line 5) | type GenerateContentRequest struct
type Message (line 14) | type Message struct
type GenerateContentResponse (line 19) | type GenerateContentResponse struct
type StreamingResponse (line 28) | type StreamingResponse struct
type APIError (line 33) | type APIError struct
type SummarizeRequest (line 37) | type SummarizeRequest struct
type SummarizeResponse (line 42) | type SummarizeResponse struct
type CreateEmbeddingRequest (line 49) | type CreateEmbeddingRequest struct
type CreateEmbeddingResponse (line 53) | type CreateEmbeddingResponse struct
FILE: llms/cloudflare/internal/cloudflareclient/role.go
constant RoleSystem (line 4) | RoleSystem = "system"
constant RoleTypeUser (line 5) | RoleTypeUser = "user"
constant RoleAssistant (line 6) | RoleAssistant = "assistant"
type Role (line 9) | type Role
FILE: llms/cloudflare/llmtest_test.go
function TestLLM (line 10) | func TestLLM(t *testing.T) {
FILE: llms/cloudflare/options.go
type options (line 9) | type options struct
type Option (line 19) | type Option
function WithModel (line 22) | func WithModel(model string) Option {
function WithSystemPrompt (line 32) | func WithSystemPrompt(p string) Option {
function WithAccountID (line 39) | func WithAccountID(accountID string) Option {
function WithServerURL (line 46) | func WithServerURL(rawURL string) Option {
function WithCloudflareServerURL (line 57) | func WithCloudflareServerURL(serverURL *url.URL) Option {
function WithToken (line 64) | func WithToken(token string) Option {
function WithEmbeddingModel (line 70) | func WithEmbeddingModel(model string) Option {
function WithHTTPClient (line 77) | func WithHTTPClient(client *http.Client) Option {
FILE: llms/cohere/coherellm.go
type LLM (line 20) | type LLM struct
method Call (line 27) | func (o *LLM) Call(ctx context.Context, prompt string, options ...llms...
method GenerateContent (line 32) | func (o *LLM) GenerateContent(ctx context.Context, messages []llms.Mes...
function New (line 71) | func New(opts ...Option) (*LLM, error) {
function newClient (line 78) | func newClient(opts ...Option) (*cohereclient.Client, error) {
FILE: llms/cohere/coherellm_option.go
constant tokenEnvVarName (line 4) | tokenEnvVarName = "COHERE_API_KEY"
constant modelEnvVarName (line 5) | modelEnvVarName = "COHERE_MODEL"
constant baseURLEnvVarName (line 6) | baseURLEnvVarName = "COHERE_BASE_URL"
type options (line 9) | type options struct
type Option (line 15) | type Option
function WithToken (line 19) | func WithToken(token string) Option {
function WithModel (line 27) | func WithModel(model string) Option {
function WithBaseURL (line 36) | func WithBaseURL(baseURL string) Option {
FILE: llms/cohere/coherellm_test.go
function newClientWithHTTPClient (line 16) | func newClientWithHTTPClient(httpClient *http.Client, opts ...Option) (*...
function TestNew (line 34) | func TestNew(t *testing.T) {
function TestCall (line 108) | func TestCall(t *testing.T) {
function TestGenerateContent (line 138) | func TestGenerateContent(t *testing.T) {
type testCallbackHandler (line 184) | type testCallbackHandler struct
method HandleLLMGenerateContentStart (line 190) | func (h *testCallbackHandler) HandleLLMGenerateContentStart(ctx contex...
method HandleLLMGenerateContentEnd (line 194) | func (h *testCallbackHandler) HandleLLMGenerateContentEnd(ctx context....
method HandleLLMError (line 198) | func (h *testCallbackHandler) HandleLLMError(ctx context.Context, err ...
method HandleText (line 202) | func (h *testCallbackHandler) HandleText(ctx context.Context, text str...
method HandleLLMStart (line 203) | func (h *testCallbackHandler) HandleLLMStart(ctx context.Context, prom...
method HandleChainStart (line 204) | func (h *testCallbackHandler) HandleChainStart(ctx context.Context, in...
method HandleChainEnd (line 205) | func (h *testCallbackHandler) HandleChainEnd(ctx context.Context, outp...
method HandleChainError (line 206) | func (h *testCallbackHandler) HandleChainError(ctx context.Context, er...
method HandleToolStart (line 207) | func (h *testCallbackHandler) HandleToolStart(ctx context.Context, inp...
method HandleToolEnd (line 208) | func (h *testCallbackHandler) HandleToolEnd(ctx context.Context, outpu...
method HandleToolError (line 209) | func (h *testCallbackHandler) HandleToolError(ctx context.Context, err...
method HandleAgentAction (line 210) | func (h *testCallbackHandler) HandleAgentAction(ctx context.Context, a...
method HandleAgentFinish (line 211) | func (h *testCallbackHandler) HandleAgentFinish(ctx context.Context, f...
method HandleRetrieverStart (line 212) | func (h *testCallbackHandler) HandleRetrieverStart(ctx context.Context...
method HandleRetrieverEnd (line 213) | func (h *testCallbackHandler) HandleRetrieverEnd(ctx context.Context, ...
method HandleStreamingFunc (line 215) | func (h *testCallbackHandler) HandleStreamingFunc(ctx context.Context,...
function TestCallbacksHandler (line 217) | func TestCallbacksHandler(t *testing.T) {
type mockHTTPClient (line 272) | type mockHTTPClient struct
method Do (line 277) | func (m *mockHTTPClient) Do(req *http.Request) (*http.Response, error) {
type mockBody (line 285) | type mockBody struct
method Read (line 294) | func (m *mockBody) Read(p []byte) (n int, err error) {
method Close (line 303) | func (m *mockBody) Close() error {
function newMockBody (line 290) | func newMockBody(content string) *mockBody {
FILE: llms/cohere/errors.go
type errorMapping (line 10) | type errorMapping struct
function MapError (line 61) | func MapError(err error) error {
FILE: llms/cohere/internal/cohereclient/cohereclient.go
type Client (line 21) | type Client struct
method CreateGeneration (line 90) | func (c *Client) CreateGeneration(ctx context.Context, r *GenerationRe...
type Option (line 29) | type Option
type Doer (line 32) | type Doer interface
function WithHTTPClient (line 37) | func WithHTTPClient(client Doer) Option {
function New (line 45) | func New(token string, baseURL string, model string, opts ...Option) (*C...
type GenerationRequest (line 68) | type GenerationRequest struct
type Generation (line 72) | type Generation struct
type generateRequestPayload (line 76) | type generateRequestPayload struct
type generateResponsePayload (line 81) | type generateResponsePayload struct
FILE: llms/cohere/internal/cohereclient/cohereclient_test.go
function setupTestClient (line 15) | func setupTestClient(t *testing.T, baseURL, model string) (*Client, *htt...
function TestClient_CreateGeneration (line 31) | func TestClient_CreateGeneration(t *testing.T) {
function TestClient_CreateGenerationWithCustomModel (line 48) | func TestClient_CreateGenerationWithCustomModel(t *testing.T) {
FILE: llms/cohere/llmtest_test.go
function TestLLM (line 10) | func TestLLM(t *testing.T) {
FILE: llms/compliance/example_test.go
function TestFakeProviderCompliance (line 12) | func TestFakeProviderCompliance(t *testing.T) {
function TestOpenAIComplianceExample (line 46) | func TestOpenAIComplianceExample(t *testing.T) {
FILE: llms/compliance/suite.go
type Suite (line 13) | type Suite struct
method Skip (line 38) | func (s *Suite) Skip(testName string) {
method Run (line 43) | func (s *Suite) Run(t *testing.T) {
method testBasicGeneration (line 65) | func (s *Suite) testBasicGeneration(t *testing.T) {
method testMultiMessage (line 88) | func (s *Suite) testMultiMessage(t *testing.T) {
method testTemperature (line 113) | func (s *Suite) testTemperature(t *testing.T) {
method testMaxTokens (line 149) | func (s *Suite) testMaxTokens(t *testing.T) {
method testStopSequences (line 174) | func (s *Suite) testStopSequences(t *testing.T) {
function NewSuite (line 28) | func NewSuite(provider string, model llms.Model) *Suite {
FILE: llms/count_tokens.go
constant _tokenApproximation (line 10) | _tokenApproximation = 4
constant _gpt35TurboContextSize (line 14) | _gpt35TurboContextSize = 16385
constant _gpt35Turbo16KContextSize (line 15) | _gpt35Turbo16KContextSize = 16385
constant _gpt4ContextSize (line 16) | _gpt4ContextSize = 8192
constant _gpt432KContextSize (line 17) | _gpt432KContextSize = 32768
constant _gpt4TurboContextSize (line 18) | _gpt4TurboContextSize = 128000
constant _gpt4oContextSize (line 19) | _gpt4oContextSize = 128000
constant _gpt4oMiniContextSize (line 20) | _gpt4oMiniContextSize = 128000
constant _textDavinci3ContextSize (line 21) | _textDavinci3ContextSize = 4097
constant _textBabbage1ContextSize (line 22) | _textBabbage1ContextSize = 2048
constant _textAda1ContextSize (line 23) | _textAda1ContextSize = 2048
constant _textCurie1ContextSize (line 24) | _textCurie1ContextSize = 2048
constant _codeDavinci2ContextSize (line 25) | _codeDavinci2ContextSize = 8000
constant _codeCushman1ContextSize (line 26) | _codeCushman1ContextSize = 2048
constant _defaultContextSize (line 27) | _defaultContextSize = 2048
function GetModelContextSize (line 65) | func GetModelContextSize(model string) int {
function CountTokens (line 74) | func CountTokens(model, text string) int {
function CalculateMaxTokens (line 87) | func CalculateMaxTokens(model, text string) int {
FILE: llms/count_tokens_test.go
function TestCountTokens (line 9) | func TestCountTokens(t *testing.T) {
function TestGetModelContextSize (line 16) | func TestGetModelContextSize(t *testing.T) {
FILE: llms/ernie/erniellm.go
type LLM (line 19) | type LLM struct
method Call (line 69) | func (o *LLM) Call(ctx context.Context, prompt string, options ...llms...
method GenerateContent (line 74) | func (o *LLM) GenerateContent(ctx context.Context, messages []llms.Mes...
method CreateEmbedding (line 129) | func (o *LLM) CreateEmbedding(ctx context.Context, texts []string) ([]...
method getModelPath (line 148) | func (o *LLM) getModelPath(opts llms.CallOptions) ernieclient.ModelPath {
function New (line 28) | func New(opts ...Option) (*LLM, error) {
function newClient (line 47) | func newClient(opts *options) (*ernieclient.Client, error) {
function modelToPath (line 158) | func modelToPath(model ModelName) ernieclient.ModelPath {
FILE: llms/ernie/erniellm_option.go
constant ernieAPIKey (line 10) | ernieAPIKey = "ERNIE_API_KEY"
constant ernieSecretKey (line 11) | ernieSecretKey = "ERNIE_SECRET_KEY"
type ModelName (line 14) | type ModelName
constant ModelNameERNIEBot (line 17) | ModelNameERNIEBot = "ERNIE-Bot"
constant ModelNameERNIEBotTurbo (line 18) | ModelNameERNIEBotTurbo = "ERNIE-Bot-turbo"
constant ModelNameERNIEBotPro (line 19) | ModelNameERNIEBotPro = "ERNIE-Bot-pro"
constant ModelNameBloomz7B (line 20) | ModelNameBloomz7B = "BLOOMZ-7B"
constant ModelNameLlama2_7BChat (line 21) | ModelNameLlama2_7BChat = "Llama-2-7b-chat"
constant ModelNameLlama2_13BChat (line 22) | ModelNameLlama2_13BChat = "Llama-2-13b-chat"
constant ModelNameLlama2_70BChat (line 23) | ModelNameLlama2_70BChat = "Llama-2-70b-chat"
type options (line 26) | type options struct
type Option (line 38) | type Option
function WithAKSK (line 49) | func WithAKSK(apiKey, secretKey string) Option {
function WithAccessToken (line 57) | func WithAccessToken(accessToken string) Option {
function WithModelName (line 64) | func WithModelName(modelName ModelName) Option {
function WithCallbackHandler (line 71) | func WithCallbackHandler(callbacksHandler callbacks.Handler) Option {
function WithAPIKey (line 78) | func WithAPIKey(apiKey string) Option {
function WithSecretKey (line 85) | func WithSecretKey(secretKey string) Option {
function WithModel (line 92) | func WithModel(modelName string) Option {
function WithBaseURL (line 99) | func WithBaseURL(baseURL string) Option {
function WithModelPath (line 106) | func WithModelPath(modelPath string) Option {
function WithCacheType (line 113) | func WithCacheType(cacheType string) Option {
function WithHTTPClient (line 120) | func WithHTTPClient(client *http.Client) Option {
FILE: llms/ernie/erniellm_test.go
function TestNew (line 18) | func TestNew(t *testing.T) {
function TestOptions (line 90) | func TestOptions(t *testing.T) {
function newErnieTestLLM (line 141) | func newErnieTestLLM(t *testing.T, opts ...Option) *LLM {
function hasExistingRecording (line 176) | func hasExistingRecording(t *testing.T) bool {
function TestLLM_Call (line 184) | func TestLLM_Call(t *testing.T) {
function TestLLM_GenerateContent (line 193) | func TestLLM_GenerateContent(t *testing.T) {
function TestLLM_CreateEmbedding (line 212) | func TestLLM_CreateEmbedding(t *testing.T) {
FILE: llms/ernie/internal/ernieclient/chat.go
constant defaultBaseURL (line 18) | defaultBaseURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1"
constant streamStopFlag (line 19) | streamStopFlag = "\"is_end\": true"
type ChatRequest (line 23) | type ChatRequest struct
type ChatMessage (line 52) | type ChatMessage struct
type ChatChoice (line 66) | type ChatChoice struct
type ChatUsage (line 73) | type ChatUsage struct
type ChatResponse (line 79) | type ChatResponse struct
type FunctionCallRes (line 94) | type FunctionCallRes struct
type StreamedChatResponsePayload (line 100) | type StreamedChatResponsePayload struct
type FunctionDefinition (line 118) | type FunctionDefinition struct
type FunctionCallBehavior (line 128) | type FunctionCallBehavior
constant FunctionCallBehaviorUnspecified (line 132) | FunctionCallBehaviorUnspecified FunctionCallBehavior = ""
constant FunctionCallBehaviorNone (line 134) | FunctionCallBehaviorNone FunctionCallBehavior = "none"
constant FunctionCallBehaviorAuto (line 136) | FunctionCallBehaviorAuto FunctionCallBehavior = "auto"
type FunctionCall (line 140) | type FunctionCall struct
method createChat (line 147) | func (c *Client) createChat(ctx context.Context, payload *ChatRequest) (...
function parseStreamingChatResponse (line 193) | func parseStreamingChatResponse(ctx context.Context, r *http.Response, p...
type errorMessage (line 247) | type errorMessage struct
FILE: llms/ernie/internal/ernieclient/client_unit_test.go
type mockHTTPClient (line 20) | type mockHTTPClient struct
method Do (line 35) | func (m *mockHTTPClient) Do(req *http.Request) (*http.Response, error) {
method getRequests (line 64) | func (m *mockHTTPClient) getRequests() []*http.Request {
type mockResponse (line 29) | type mockResponse struct
function TestNew (line 70) | func TestNew(t *testing.T) {
function TestClient_CreateCompletion_Unit (line 171) | func TestClient_CreateCompletion_Unit(t *testing.T) {
function TestClient_CreateEmbedding_Unit (line 310) | func TestClient_CreateEmbedding_Unit(t *testing.T) {
function TestClient_CreateChat_Unit (line 394) | func TestClient_CreateChat_Unit(t *testing.T) {
function TestClient_getAccessToken (line 535) | func TestClient_getAccessToken(t *testing.T) {
function TestClient_buildURL (line 614) | func TestClient_buildURL(t *testing.T) {
function TestClient_setHeaders (line 644) | func TestClient_setHeaders(t *testing.T) {
function TestParseStreamingCompletionResponse (line 654) | func TestParseStreamingCompletionResponse(t *testing.T) {
function TestParseStreamingChatResponse (line 717) | func TestParseStreamingChatResponse(t *testing.T) {
function TestAutoRefresh (line 776) | func TestAutoRefresh(t *testing.T) {
function TestChatMessageMarshaling (line 824) | func TestChatMessageMarshaling(t *testing.T) {
function TestCompletionRequestMarshaling (line 870) | func TestCompletionRequestMarshaling(t *testing.T) {
function TestErrorScenarios (line 895) | func TestErrorScenarios(t *testing.T) {
function TestConcurrentAccessTokenUpdate (line 965) | func TestConcurrentAccessTokenUpdate(t *testing.T) {
function TestRequestBodyReading (line 1002) | func TestRequestBodyReading(t *testing.T) {
function TestInvalidJSONResponse (line 1037) | func TestInvalidJSONResponse(t *testing.T) {
function TestResponseBodyClosure (line 1093) | func TestResponseBodyClosure(t *testing.T) {
type trackingCloser (line 1135) | type trackingCloser struct
method Close (line 1140) | func (t *trackingCloser) Close() error {
function TestEmptyModelPath (line 1147) | func TestEmptyModelPath(t *testing.T) {
function TestCreateChatWithoutFunctions (line 1159) | func TestCreateChatWithoutFunctions(t *testing.T) {
function TestEmbeddingRequestMarshaling (line 1192) | func TestEmbeddingRequestMarshaling(t *testing.T) {
function TestHTTPClientNilCheck (line 1208) | func TestHTTPClientNilCheck(t *testing.T) {
function TestWithAKSKOption (line 1215) | func TestWithAKSKOption(t *testing.T) {
function TestResponseReaderError (line 1226) | func TestResponseReaderError(t *testing.T) {
type failingReader (line 1256) | type failingReader struct
method Read (line 1262) | func (f *failingReader) Read(p []byte) (n int, err error) {
FILE: llms/ernie/internal/ernieclient/ernieclient.go
type Client (line 28) | type Client struct
method CreateCompletion (line 192) | func (c *Client) CreateCompletion(ctx context.Context, modelPath Model...
method CreateEmbedding (line 230) | func (c *Client) CreateEmbedding(ctx context.Context, texts []string) ...
method getAccessToken (line 265) | func (c *Client) getAccessToken(ctx context.Context) (*authResponse, e...
method CreateChat (line 290) | func (c *Client) CreateChat(ctx context.Context, r *ChatRequest) (*Cha...
method buildURL (line 355) | func (c *Client) buildURL(modelpath ModelPath) string {
method setHeaders (line 369) | func (c *Client) setHeaders(req *http.Request) {
type ModelPath (line 39) | type ModelPath
constant DefaultCompletionModelPath (line 43) | DefaultCompletionModelPath = "completions"
constant tryPeriod (line 44) | tryPeriod = 3
constant defaultFunctionCallBehavior (line 45) | defaultFunctionCallBehavior = "auto"
type Option (line 49) | type Option
type Doer (line 52) | type Doer interface
type Message (line 56) | type Message struct
type CompletionRequest (line 62) | type CompletionRequest struct
type Completion (line 73) | type Completion struct
type EmbeddingResponse (line 92) | type EmbeddingResponse struct
type authResponse (line 110) | type authResponse struct
function WithHTTPClient (line 120) | func WithHTTPClient(client Doer) Option {
function WithAKSK (line 128) | func WithAKSK(apiKey, secretKey string) Option {
function WithAccessToken (line 137) | func WithAccessToken(accessToken string) Option {
function New (line 145) | func New(opts ...Option) (*Client, error) {
function autoRefresh (line 169) | func autoRefresh(c *Client) error {
function parseStreamingCompletionResponse (line 306) | func parseStreamingCompletionResponse(ctx context.Context, resp *http.Re...
FILE: llms/ernie/internal/ernieclient/ernieclient_test.go
function requireErnieCredentialsOrHTTPRR (line 15) | func requireErnieCredentialsOrHTTPRR(t *testing.T) *httprr.RecordReplay {
function TestClient_CreateCompletion (line 36) | func TestClient_CreateCompletion(t *testing.T) {
function TestClient_CreateCompletionStream (line 84) | func TestClient_CreateCompletionStream(t *testing.T) {
function newErnieTestClient (line 137) | func newErnieTestClient(t *testing.T) *Client {
function TestClient_CreateChat (line 169) | func TestClient_CreateChat(t *testing.T) {
function TestClient_CreateEmbedding (line 191) | func TestClient_CreateEmbedding(t *testing.T) {
FILE: llms/ernie/llmtest_test.go
function TestLLM (line 10) | func TestLLM(t *testing.T) {
FILE: llms/errors.go
type ErrorCode (line 10) | type ErrorCode
constant ErrCodeUnknown (line 14) | ErrCodeUnknown ErrorCode = "unknown"
constant ErrCodeAuthentication (line 17) | ErrCodeAuthentication ErrorCode = "authentication"
constant ErrCodeRateLimit (line 20) | ErrCodeRateLimit ErrorCode = "rate_limit"
constant ErrCodeInvalidRequest (line 23) | ErrCodeInvalidRequest ErrorCode = "invalid_request"
constant ErrCodeResourceNotFound (line 26) | ErrCodeResourceNotFound ErrorCode = "resource_not_found"
constant ErrCodeTimeout (line 29) | ErrCodeTimeout ErrorCode = "timeout"
constant ErrCodeCanceled (line 32) | ErrCodeCanceled ErrorCode = "canceled"
constant ErrCodeQuotaExceeded (line 35) | ErrCodeQuotaExceeded ErrorCode = "quota_exceeded"
constant ErrCodeContentFilter (line 38) | ErrCodeContentFilter ErrorCode = "content_filter"
constant ErrCodeTokenLimit (line 41) | ErrCodeTokenLimit ErrorCode = "token_limit"
constant ErrCodeProviderUnavailable (line 44) | ErrCodeProviderUnavailable ErrorCode = "provider_unavailable"
constant ErrCodeNotImplemented (line 47) | ErrCodeNotImplemented ErrorCode = "not_implemented"
type Error (line 51) | type Error struct
method Error (line 69) | func (e *Error) Error() string {
method Unwrap (line 77) | func (e *Error) Unwrap() error {
method Is (line 82) | func (e *Error) Is(target error) bool {
method WithCause (line 114) | func (e *Error) WithCause(cause error) *Error {
method WithDetail (line 120) | func (e *Error) WithDetail(key string, value interface{}) *Error {
function NewError (line 104) | func NewError(code ErrorCode, provider, message string) *Error {
function IsAuthenticationError (line 129) | func IsAuthenticationError(err error) bool {
function IsRateLimitError (line 135) | func IsRateLimitError(err error) bool {
function IsInvalidRequestError (line 141) | func IsInvalidRequestError(err error) bool {
function IsTimeoutError (line 147) | func IsTimeoutError(err error) bool {
function IsCanceledError (line 153) | func IsCanceledError(err error) bool {
function IsQuotaExceededError (line 159) | func IsQuotaExceededError(err error) bool {
function IsContentFilterError (line 165) | func IsContentFilterError(err error) bool {
function IsTokenLimitError (line 171) | func IsTokenLimitError(err error) bool {
function IsProviderUnavailableError (line 177) | func IsProviderUnavailableError(err error) bool {
function IsNotImplementedError (line 183) | func IsNotImplementedError(err error) bool {
FILE: llms/errors_mapper.go
type ErrorMapper (line 11) | type ErrorMapper struct
method AddMatcher (line 115) | func (m *ErrorMapper) AddMatcher(matcher ErrorMatcher) *ErrorMapper {
method WrapError (line 122) | func (m *ErrorMapper) WrapError(err error) error {
method Map (line 151) | func (m *ErrorMapper) Map(err error) error {
type ErrorMatcher (line 17) | type ErrorMatcher struct
function NewErrorMapper (line 27) | func NewErrorMapper(provider string) *ErrorMapper {
function defaultMatchers (line 35) | func defaultMatchers() []ErrorMatcher {
function contextErrorMatchers (line 48) | func contextErrorMatchers() []ErrorMatcher {
function stringPatternMatchers (line 73) | func stringPatternMatchers() []ErrorMatcher {
function makeStringMatcher (line 99) | func makeStringMatcher(patterns []string, code ErrorCode) ErrorMatcher {
function OpenAIErrorMapper (line 156) | func OpenAIErrorMapper() *ErrorMapper {
function AnthropicErrorMapper (line 186) | func AnthropicErrorMapper() *ErrorMapper {
function GoogleAIErrorMapper (line 216) | func GoogleAIErrorMapper() *ErrorMapper {
FILE: llms/errors_test.go
function TestStandardError (line 13) | func TestStandardError(t *testing.T) {
function TestErrorIs (line 53) | func TestErrorIs(t *testing.T) {
function TestErrorHelpers (line 98) | func TestErrorHelpers(t *testing.T) {
function TestErrorMapper (line 146) | func TestErrorMapper(t *testing.T) {
function TestProviderSpecificMappers (line 225) | func TestProviderSpecificMappers(t *testing.T) {
function TestCustomMatcher (line 264) | func TestCustomMatcher(t *testing.T) {
type timeoutError (line 296) | type timeoutError struct
method Error (line 298) | func (e *timeoutError) Error() string { return "timeout" }
method Timeout (line 299) | func (e *timeoutError) Timeout() bool { return true }
method Temporary (line 300) | func (e *timeoutError) Temporary() bool { return true }
FILE: llms/fake/fakellm.go
type LLM (line 10) | type LLM struct
method GenerateContent (line 23) | func (f *LLM) GenerateContent(_ context.Context, _ []llms.MessageConte...
method Call (line 38) | func (f *LLM) Call(ctx context.Context, prompt string, options ...llms...
method Reset (line 50) | func (f *LLM) Reset() {
method AddResponse (line 55) | func (f *LLM) AddResponse(response string) {
function NewFakeLLM (line 15) | func NewFakeLLM(responses []string) *LLM {
FILE: llms/fake/fakellm_test.go
function TestFakeLLM_CallMethod (line 12) | func TestFakeLLM_CallMethod(t *testing.T) {
function TestFakeLLM_GenerateContentMethod (line 36) | func TestFakeLLM_GenerateContentMethod(t *testing.T) {
function TestFakeLLM_ResetMethod (line 71) | func TestFakeLLM_ResetMethod(t *testing.T) {
function TestFakeLLM_AddResponseMethod (line 83) | func TestFakeLLM_AddResponseMethod(t *testing.T) {
function TestFakeLLM_WithChain (line 109) | func TestFakeLLM_WithChain(t *testing.T) {
function setupResponses (line 129) | func setupResponses() []string {
function NextToResponse (line 137) | func NextToResponse(fakeLLM *LLM, n int) {
FILE: llms/fake/llmtest_test.go
function TestLLM (line 9) | func TestLLM(t *testing.T) {
FILE: llms/generatecontent.go
type MessageContent (line 14) | type MessageContent struct
function TextPart (line 20) | func TextPart(s string) TextContent {
function BinaryPart (line 26) | func BinaryPart(mime string, data []byte) BinaryContent {
function ImageURLPart (line 34) | func ImageURLPart(url string) ImageURLContent {
function ImageURLWithDetailPart (line 41) | func ImageURLWithDetailPart(url string, detail string) ImageURLContent {
type ContentPart (line 49) | type ContentPart interface
type TextContent (line 54) | type TextContent struct
method String (line 58) | func (tc TextContent) String() string {
method isPart (line 62) | func (TextContent) isPart() {}
type ImageURLContent (line 65) | type ImageURLContent struct
method String (line 70) | func (iuc ImageURLContent) String() string {
method isPart (line 74) | func (ImageURLContent) isPart() {}
type BinaryContent (line 77) | type BinaryContent struct
method String (line 82) | func (bc BinaryContent) String() string {
method isPart (line 87) | func (BinaryContent) isPart() {}
type FunctionCall (line 90) | type FunctionCall struct
type ToolCall (line 98) | type ToolCall struct
method isPart (line 107) | func (ToolCall) isPart() {}
type ToolCallResponse (line 110) | type ToolCallResponse struct
method isPart (line 119) | func (ToolCallResponse) isPart() {}
type ContentResponse (line 123) | type ContentResponse struct
type ContentChoice (line 129) | type ContentChoice struct
function TextParts (line 153) | func TextParts(role ChatMessageType, parts ...string) MessageContent {
function ShowMessageContents (line 165) | func ShowMessageContents(w io.Writer, msgs []MessageContent) {
FILE: llms/generatecontent_test.go
function TestTextParts (line 8) | func TestTextParts(t *testing.T) {
FILE: llms/googleai/caching.go
type CachingHelper (line 15) | type CachingHelper struct
method CreateCachedContent (line 50) | func (ch *CachingHelper) CreateCachedContent(
method GetCachedContent (line 107) | func (ch *CachingHelper) GetCachedContent(ctx context.Context, name st...
method DeleteCachedContent (line 112) | func (ch *CachingHelper) DeleteCachedContent(ctx context.Context, name...
method ListCachedContents (line 117) | func (ch *CachingHelper) ListCachedContents(ctx context.Context) *gena...
function NewCachingHelper (line 20) | func NewCachingHelper(ctx context.Context, opts ...Option) (*CachingHelp...
FILE: llms/googleai/embeddings.go
method CreateEmbedding (line 11) | func (g *GoogleAI) CreateEmbedding(ctx context.Context, texts []string) ...
FILE: llms/googleai/embeddings_unit_test.go
type MockEmbeddingModel (line 15) | type MockEmbeddingModel struct
method NewBatch (line 19) | func (m *MockEmbeddingModel) NewBatch() *MockBatchEmbedder {
method BatchEmbedContents (line 24) | func (m *MockEmbeddingModel) BatchEmbedContents(ctx context.Context, b...
type MockBatchEmbedder (line 29) | type MockBatchEmbedder struct
method AddContent (line 34) | func (m *MockBatchEmbedder) AddContent(content genai.Text) *MockBatchE...
type MockGenAIClient (line 39) | type MockGenAIClient struct
method EmbeddingModel (line 43) | func (m *MockGenAIClient) EmbeddingModel(name string) *MockEmbeddingMo...
function TestCreateEmbedding_ConceptualTests (line 52) | func TestCreateEmbedding_ConceptualTests(t *testing.T) {
function TestEmbeddingBatchLogic (line 112) | func TestEmbeddingBatchLogic(t *testing.T) {
function TestEmbeddingConstants (line 147) | func TestEmbeddingConstants(t *testing.T) {
function TestCreateEmbedding_ErrorScenarios (line 161) | func TestCreateEmbedding_ErrorScenarios(t *testing.T) {
function TestCreateEmbedding_Integration_Placeholder (line 178) | func TestCreateEmbedding_Integration_Placeholder(t *testing.T) {
function TestEmbeddingInputValidation (line 191) | func TestEmbeddingInputValidation(t *testing.T) {
function TestEmbeddingOutputValidation (line 223) | func TestEmbeddingOutputValidation(t *testing.T) {
FILE: llms/googleai/errors.go
type errorMapping (line 10) | type errorMapping struct
function MapError (line 61) | func MapError(err error) error {
FILE: llms/googleai/googleai.go
constant CITATIONS (line 25) | CITATIONS = "citations"
constant SAFETY (line 26) | SAFETY = "safety"
constant RoleSystem (line 27) | RoleSystem = "system"
constant RoleModel (line 28) | RoleModel = "model"
constant RoleUser (line 29) | RoleUser = "user"
constant RoleTool (line 30) | RoleTool = "tool"
constant ResponseMIMETypeJson (line 31) | ResponseMIMETypeJson = "application/json"
method Call (line 35) | func (g *GoogleAI) Call(ctx context.Context, prompt string, options ...l...
method GenerateContent (line 40) | func (g *GoogleAI) GenerateContent(
function convertCandidates (line 136) | func convertCandidates(candidates []*genai.Candidate, usage *genai.Usage...
function convertParts (line 210) | func convertParts(parts []llms.ContentPart) ([]genai.Part, error) {
function convertContent (line 251) | func convertContent(content llms.MessageContent) (*genai.Content, error) {
function generateFromSingleMessage (line 283) | func generateFromSingleMessage(
function generateFromMessages (line 311) | func generateFromMessages(
function convertAndStreamFromIterator (line 359) | func convertAndStreamFromIterator(
function convertSchemaRecursive (line 405) | func convertSchemaRecursive(schemaMap map[string]any, toolIndex int, pro...
function convertTools (line 493) | func convertTools(tools []llms.Tool) ([]*genai.Tool, error) {
function convertToolSchemaType (line 538) | func convertToolSchemaType(ty string) genai.Type {
function showContent (line 558) | func showContent(w io.Writer, cs []*genai.Content) {
FILE: llms/googleai/googleai_core_unit_test.go
function TestConvertParts (line 12) | func TestConvertParts(t *testing.T) { //nolint:funlen // comprehensive test
function TestConvertContent (line 122) | func TestConvertContent(t *testing.T) { //nolint:funlen // comprehensive...
function TestConvertCandidates (line 235) | func TestConvertCandidates(t *testing.T) { //nolint:funlen // comprehens...
function TestCall (line 372) | func TestCall(t *testing.T) {
function TestGenerateContentOptionsHandling (line 385) | func TestGenerateContentOptionsHandling(t *testing.T) {
function TestRoleMapping (line 429) | func TestRoleMapping(t *testing.T) {
function TestFunctionCallConversion (line 467) | func TestFunctionCallConversion(t *testing.T) {
function TestSafetySettings (line 512) | func TestSafetySettings(t *testing.T) {
FILE: llms/googleai/googleai_test.go
function hasExistingRecording (line 19) | func hasExistingRecording(t *testing.T) bool {
function newHTTPRRClient (line 27) | func newHTTPRRClient(t *testing.T, opts ...Option) *GoogleAI {
function TestGoogleAIGenerateContent (line 76) | func TestGoogleAIGenerateContent(t *testing.T) {
function TestGoogleAIGenerateContentWithMultipleMessages (line 102) | func TestGoogleAIGenerateContentWithMultipleMessages(t *testing.T) {
function TestGoogleAIGenerateContentWithSystemMessage (line 140) | func TestGoogleAIGenerateContentWithSystemMessage(t *testing.T) {
function TestGoogleAICall (line 171) | func TestGoogleAICall(t *testing.T) {
function TestGoogleAICreateEmbedding (line 187) | func TestGoogleAICreateEmbedding(t *testing.T) {
function TestGoogleAIWithOptions (line 209) | func TestGoogleAIWithOptions(t *testing.T) {
function TestGoogleAIWithStreaming (line 238) | func TestGoogleAIWithStreaming(t *testing.T) {
function TestGoogleAIWithTools (line 281) | func TestGoogleAIWithTools(t *testing.T) {
function TestGoogleAIWithJSONMode (line 338) | func TestGoogleAIWithJSONMode(t *testing.T) {
function TestGoogleAIErrorHandling (line 371) | func TestGoogleAIErrorHandling(t *testing.T) {
function TestGoogleAIMultiModalContent (line 415) | func TestGoogleAIMultiModalContent(t *testing.T) {
function TestGoogleAIBatchEmbedding (line 456) | func TestGoogleAIBatchEmbedding(t *testing.T) {
function TestGoogleAIWithHarmThreshold (line 481) | func TestGoogleAIWithHarmThreshold(t *testing.T) {
function TestGoogleAIToolCallResponse (line 508) | func TestGoogleAIToolCallResponse(t *testing.T) {
FILE: llms/googleai/googleai_unit_test.go
function TestNew (line 11) | func TestNew(t *testing.T) {
function TestDefaultOptions (line 84) | func TestDefaultOptions(t *testing.T) {
function TestOptions (line 101) | func TestOptions(t *testing.T) { //nolint:funlen // comprehensive test /...
function TestEnsureAuthPresent (line 208) | func TestEnsureAuthPresent(t *testing.T) {
function TestHasAuthOptions (line 236) | func TestHasAuthOptions(t *testing.T) {
function TestHarmBlockThresholdConstants (line 248) | func TestHarmBlockThresholdConstants(t *testing.T) {
function TestConstants (line 258) | func TestConstants(t *testing.T) {
function TestErrorConstants (line 270) | func TestErrorConstants(t *testing.T) {
function TestGoogleAIImplementsModelInterface (line 278) | func TestGoogleAIImplementsModelInterface(t *testing.T) {
function TestConvertToolSchemaType (line 285) | func TestConvertToolSchemaType(t *testing.T) {
function TestConvertTools (line 310) | func TestConvertTools(t *testing.T) { //nolint:funlen // comprehensive t...
FILE: llms/googleai/internal/cmd/generate-vertex.go
function main (line 18) | func main() {
constant preamble (line 47) | preamble = `
function rewriteImport (line 52) | func rewriteImport(x *ast.ImportSpec) {
function rewriteReceiverName (line 58) | func rewriteReceiverName(fun *ast.FuncDecl) {
function addCastToTopK (line 65) | func addCastToTopK(fun *ast.FuncDecl) {
function removeTokenCount (line 85) | func removeTokenCount(fun *ast.FuncDecl) {
function getIdentName (line 109) | func getIdentName(x ast.Expr) string {
FILE: llms/googleai/internal/palmclient/palm_client_option.go
constant embeddingModelName (line 8) | embeddingModelName = "text-embedding-005"
constant TextModelName (line 9) | TextModelName = "text-bison"
constant ChatModelName (line 10) | ChatModelName = "chat-bison"
type Options (line 14) | type Options struct
type Option (line 22) | type Option
function WithEmbeddingModelName (line 25) | func WithEmbeddingModelName(modelName string) Option {
function WithTextModelName (line 34) | func WithTextModelName(modelName string) Option {
function WithChatModelName (line 43) | func WithChatModelName(modelName string) Option {
function WithClientOptions (line 52) | func WithClientOptions(opts ...option.ClientOption) Option {
function defaultOptions (line 58) | func defaultOptions() Options {
FILE: llms/googleai/internal/palmclient/palmclient.go
constant defaultMaxConns (line 31) | defaultMaxConns = 4
type PaLMClient (line 35) | type PaLMClient struct
method CreateCompletion (line 95) | func (c *PaLMClient) CreateCompletion(ctx context.Context, r *Completi...
method CreateEmbedding (line 127) | func (c *PaLMClient) CreateEmbedding(ctx context.Context, r *Embedding...
method CreateChat (line 204) | func (c *PaLMClient) CreateChat(ctx context.Context, r *ChatRequest) (...
method batchPredict (line 289) | func (c *PaLMClient) batchPredict(ctx context.Context, model string, p...
method chat (line 312) | func (c *PaLMClient) chat(ctx context.Context, r *ChatRequest) ([]*str...
method projectLocationPublisherModelPath (line 351) | func (c *PaLMClient) projectLocationPublisherModelPath(projectID, loca...
function New (line 44) | func New(ctx context.Context, projectID, location string, opts ...Option...
type CompletionRequest (line 80) | type CompletionRequest struct
type Completion (line 90) | type Completion struct
type EmbeddingRequest (line 122) | type EmbeddingRequest struct
type ChatRequest (line 163) | type ChatRequest struct
type ChatMessage (line 173) | type ChatMessage struct
method GetType (line 184) | func (m ChatMessage) GetType() llms.ChatMessageType {
method GetContent (line 194) | func (m ChatMessage) GetContent() string {
type ChatResponse (line 199) | type ChatResponse struct
function mergeParams (line 237) | func mergeParams(defaultParams, params map[string]interface{}) *structpb...
function convertToOutputStruct (line 264) | func convertToOutputStruct(defaultParams map[string]interface{}, mergedP...
function cloneDefaultParameters (line 273) | func cloneDefaultParameters() map[string]interface{} {
function convertArray (line 281) | func convertArray(value []string) interface{} {
FILE: llms/googleai/internal/palmclient/palmclient_unit_test.go
function TestChatMessage_GetType (line 13) | func TestChatMessage_GetType(t *testing.T) {
function TestChatMessage_GetContent (line 51) | func TestChatMessage_GetContent(t *testing.T) {
function TestConvertArray (line 59) | func TestConvertArray(t *testing.T) {
function TestCloneDefaultParameters (line 71) | func TestCloneDefaultParameters(t *testing.T) {
function TestMergeParams (line 85) | func TestMergeParams(t *testing.T) {
function TestConvertToOutputStruct (line 160) | func TestConvertToOutputStruct(t *testing.T) {
function TestProjectLocationPublisherModelPath (line 183) | func TestProjectLocationPublisherModelPath(t *testing.T) {
function TestCompletionRequestValidation (line 195) | func TestCompletionRequestValidation(t *testing.T) {
function TestEmbeddingRequestValidation (line 211) | func TestEmbeddingRequestValidation(t *testing.T) {
function TestChatRequestValidation (line 220) | func TestChatRequestValidation(t *testing.T) {
function TestProcessPredictionsErrors (line 251) | func TestProcessPredictionsErrors(t *testing.T) {
function TestChatResponseProcessing (line 311) | func TestChatResponseProcessing(t *testing.T) {
function TestEmbeddingProcessing (line 347) | func TestEmbeddingProcessing(t *testing.T) {
function TestConstants (line 376) | func TestConstants(t *testing.T) {
function TestDefaultParameters (line 384) | func TestDefaultParameters(t *testing.T) {
function TestErrors (line 392) | func TestErrors(t *testing.T) {
function TestMergeParamsEdgeCases (line 399) | func TestMergeParamsEdgeCases(t *testing.T) {
FILE: llms/googleai/llmtest_test.go
function TestLLM (line 11) | func TestLLM(t *testing.T) {
FILE: llms/googleai/new.go
type GoogleAI (line 15) | type GoogleAI struct
method Close (line 52) | func (g *GoogleAI) Close() error {
method SupportsReasoning (line 61) | func (g *GoogleAI) SupportsReasoning() bool {
function New (line 28) | func New(ctx context.Context, opts ...Option) (*GoogleAI, error) {
FILE: llms/googleai/option.go
type Options (line 15) | type Options struct
method EnsureAuthPresent (line 46) | func (o *Options) EnsureAuthPresent() {
function DefaultOptions (line 30) | func DefaultOptions() Options {
type Option (line 54) | type Option
function WithAPIKey (line 58) | func WithAPIKey(apiKey string) Option {
function WithCredentialsJSON (line 67) | func WithCredentialsJSON(credentialsJSON []byte) Option {
function WithCredentialsFile (line 79) | func WithCredentialsFile(credentialsFile string) Option {
function WithRest (line 89) | func WithRest() Option {
function WithHTTPClient (line 98) | func WithHTTPClient(httpClient *http.Client) Option {
function WithGRPCConn (line 107) | func WithGRPCConn(conn *grpc.ClientConn) Option {
function WithCloudProject (line 115) | func WithCloudProject(p string) Option {
function WithCloudLocation (line 123) | func WithCloudLocation(l string) Option {
function WithDefaultModel (line 131) | func WithDefaultModel(defaultModel string) Option {
function WithDefaultEmbeddingModel (line 139) | func WithDefaultEmbeddingModel(defaultEmbeddingModel string) Option {
function WithDefaultCandidateCount (line 146) | func WithDefaultCandidateCount(defaultCandidateCount int) Option {
function WithDefaultMaxTokens (line 153) | func WithDefaultMaxTokens(maxTokens int) Option {
function WithDefaultTemperature (line 160) | func WithDefaultTemperature(defaultTemperature float64) Option {
function WithDefaultTopK (line 167) | func WithDefaultTopK(defaultTopK int) Option {
function WithDefaultTopP (line 174) | func WithDefaultTopP(defaultTopP float64) Option {
function WithHarmThreshold (line 182) | func WithHarmThreshold(ht HarmBlockThreshold) Option {
function WithCachedContent (line 191) | func WithCachedContent(name string) llms.CallOption {
type HarmBlockThreshold (line 200) | type HarmBlockThreshold
constant HarmBlockUnspecified (line 204) | HarmBlockUnspecified HarmBlockThreshold = 0
constant HarmBlockLowAndAbove (line 206) | HarmBlockLowAndAbove HarmBlockThreshold = 1
constant HarmBlockMediumAndAbove (line 208) | HarmBlockMediumAndAbove HarmBlockThreshold = 2
constant HarmBlockOnlyHigh (line 210) | HarmBlockOnlyHigh HarmBlockThreshold = 3
constant HarmBlockNone (line 212) | HarmBlockNone HarmBlockThreshold = 4
function hasAuthOptions (line 216) | func hasAuthOptions(opts []option.ClientOption) bool {
FILE: llms/googleai/palm/palm_llm.go
type LLM (line 23) | type LLM struct
method Call (line 31) | func (o *LLM) Call(ctx context.Context, prompt string, options ...llms...
method GenerateContent (line 36) | func (o *LLM) GenerateContent(ctx context.Context, messages []llms.Mes...
method CreateEmbedding (line 79) | func (o *LLM) CreateEmbedding(ctx context.Context, inputTexts []string...
function New (line 98) | func New(opts ...Option) (*LLM, error) {
function newClient (line 103) | func newClient(opts ...Option) (*palmclient.PaLMClient, error) {
FILE: llms/googleai/palm/palm_llm_option.go
constant projectIDEnvVarName (line 13) | projectIDEnvVarName = "GOOGLE_CLOUD_PROJECT"
constant locationEnvVarName (line 14) | locationEnvVarName = "GOOGLE_CLOUD_LOCATION"
type options (line 25) | type options struct
type Option (line 32) | type Option
function initOpts (line 35) | func initOpts() {
function WithProjectID (line 44) | func WithProjectID(projectID string) Option {
function WithLocation (line 51) | func WithLocation(location string) Option {
function WithAPIKey (line 59) | func WithAPIKey(apiKey string) Option {
function WithCredentialsFile (line 66) | func WithCredentialsFile(path string) Option {
function WithCredentialsJSON (line 73) | func WithCredentialsJSON(json []byte) Option {
function WithGRPCDialOption (line 77) | func WithGRPCDialOption(opt grpc.DialOption) Option {
function WithHTTPClient (line 83) | func WithHTTPClient(client *http.Client) Option {
function convertStringOption (line 89) | func convertStringOption(fopt func(string) option.ClientOption) func(str...
function convertByteArrayOption (line 97) | func convertByteArrayOption(fopt func([]b
Condensed preview — 1148 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (8,701K chars).
[
{
"path": ".gitattributes",
"chars": 221,
"preview": "# Mark httprr recording files as generated\n*.httprr linguist-generated=true\n*.httprr.gz linguist-generated=true\n\n# Prese"
},
{
"path": ".github/FUNDING.yml",
"chars": 58,
"preview": "# These are supported funding model platforms\ngithub: tmc\n"
},
{
"path": ".github/PULL_REQUEST_TEMPLATE.md",
"chars": 1000,
"preview": "\n### PR Checklist\n\n- [ ] Read the [Contributing documentation](https://github.com/tmc/langchaingo/blob/main/CONTRIBUTING"
},
{
"path": ".github/workflows/ci.yaml",
"chars": 5660,
"preview": "# GitHub Actions CI workflow for langchaingo.\nname: CI\non:\n push:\n branches:\n - main\n - 'test-*'\n pull_re"
},
{
"path": ".github/workflows/examples.yaml",
"chars": 1353,
"preview": "name: Build Examples\non:\n push: {}\n pull_request:\n branches:\n - main\n\npermissions:\n contents: read\n\njobs:\n d"
},
{
"path": ".github/workflows/publish-docs.yaml",
"chars": 2355,
"preview": "name: Deploy to GitHub Pages\n\non:\n workflow_dispatch:\n push:\n paths:\n - 'docs/**'\n - '.github/workflows/p"
},
{
"path": ".gitignore",
"chars": 350,
"preview": "go.work\ngo.work.sum\n\n# Test outputs\ncoverage.out\ncover.cov\n\n# macOS Specific\n.DS_Store\n.DS_Store?\n._*\n.Spotlight-V100\n.T"
},
{
"path": ".golangci-exp.yaml",
"chars": 45,
"preview": "linters:\n presets:\n - bugs\n - comment\n"
},
{
"path": ".golangci.yaml",
"chars": 741,
"preview": "version: \"2\"\nlinters:\n default: none\n enable:\n - errcheck\n - govet\n - ineffassign\n - staticcheck\n - unu"
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 3049,
"preview": "# Code of Conduct - langchaingo\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as\nco"
},
{
"path": "CONTRIBUTING.md",
"chars": 25005,
"preview": "\n# Contributing to langchaingo\n\nFirst off, thanks for taking the time to contribute! ❤️\n\nAll types of contributions are "
},
{
"path": "FIXES_SUMMARY.md",
"chars": 3589,
"preview": "# High Priority Bug Fixes Summary\n\n## Overview\nThis branch contains fixes for three high-priority issues affecting the l"
},
{
"path": "LICENSE",
"chars": 1093,
"preview": "The MIT License\n\nCopyright (c) Travis Cline <travis.cline@gmail.com>\n\nPermission is hereby granted, free of charge, to a"
},
{
"path": "Makefile",
"chars": 5256,
"preview": "# This file contains convenience targets for the project.\n# It is not intended to be used as a build system.\n# See the R"
},
{
"path": "README.md",
"chars": 3123,
"preview": "> 🎉 **Join our new official Discord community!** Connect with other LangChain Go developers, get help and contribute: [J"
},
{
"path": "agents/agents.go",
"chars": 690,
"preview": "package agents\n\nimport (\n\t\"context\"\n\n\t\"github.com/tmc/langchaingo/chains\"\n\t\"github.com/tmc/langchaingo/schema\"\n\t\"github."
},
{
"path": "agents/conversational.go",
"chars": 5312,
"preview": "package agents\n\nimport (\n\t\"context\"\n\t_ \"embed\"\n\t\"fmt\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/tmc/langchaingo/callbacks\"\n\t\"gi"
},
{
"path": "agents/conversational_test.go",
"chars": 2022,
"preview": "package agents\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\""
},
{
"path": "agents/doc.go",
"chars": 1268,
"preview": "// Package agents contains the standard interface all agents must implement,\n// implementations of this interface, and a"
},
{
"path": "agents/errors.go",
"chars": 1955,
"preview": "package agents\n\nimport \"errors\"\n\nvar (\n\t// ErrExecutorInputNotString is returned if an input to the executor call functi"
},
{
"path": "agents/executor.go",
"chars": 5151,
"preview": "package agents\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/tmc/langchaingo/callbacks\"\n\t\"github.com/tm"
},
{
"path": "agents/executor_test.go",
"chars": 6996,
"preview": "package agents_test\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"git"
},
{
"path": "agents/initialize.go",
"chars": 1342,
"preview": "package agents\n\nimport (\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaingo/tools\"\n)\n\nconst _defaultMaxIter"
},
{
"path": "agents/markl_test.go",
"chars": 1398,
"preview": "package agents\n\nimport (\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"github.com/tmc/langchaingo/schema\"\n)\n\nfunc"
},
{
"path": "agents/mrkl.go",
"chars": 5748,
"preview": "package agents\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/tmc/langchaingo/callbacks\"\n\t\"github.com/tm"
},
{
"path": "agents/mrkl_prompt.go",
"chars": 1703,
"preview": "package agents\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/tmc/langchaingo/prompts\"\n\t\"github.com/tmc/langchaingo/tools\"\n)\n"
},
{
"path": "agents/ollama_agent_guide.md",
"chars": 5943,
"preview": "# Ollama Agent Usage Guide\n\n## Issue #1045: Ollama Agents and Tools\n\n### Problem\nOllama models don't have native functio"
},
{
"path": "agents/openai_functions_agent.go",
"chars": 10238,
"preview": "package agents\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/tmc/langchaingo/callbacks\"\n\t\"github.com/tmc/la"
},
{
"path": "agents/openai_functions_agent_test.go",
"chars": 6123,
"preview": "package agents_test\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr"
},
{
"path": "agents/options.go",
"chars": 4565,
"preview": "package agents\n\nimport (\n\t\"github.com/tmc/langchaingo/callbacks\"\n\t\"github.com/tmc/langchaingo/memory\"\n\t\"github.com/tmc/l"
},
{
"path": "agents/prompts/conversational_format_instructions.txt",
"chars": 398,
"preview": "To use a tool, please use the following format:\n\nThought: Do I need to use a tool? Yes\nAction: the action to take, shoul"
},
{
"path": "agents/prompts/conversational_prefix.txt",
"chars": 1240,
"preview": "Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-d"
},
{
"path": "agents/prompts/conversational_suffix.txt",
"chars": 105,
"preview": "Begin!\n\nPrevious conversation history:\n{{.history}}\n\nNew input: {{.input}}\n\nThought:{{.agent_scratchpad}}"
},
{
"path": "agents/testdata/TestConversationalWithMemory.httprr",
"chars": 4029,
"preview": "httprr trace v1\n2269 1734\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: la"
},
{
"path": "agents/testdata/TestExecutorWithMRKLAgent.httprr",
"chars": 6240,
"preview": "httprr trace v1\n1374 1685\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: la"
},
{
"path": "agents/testdata/TestExecutorWithOpenAIFunctionAgent.httprr",
"chars": 40193,
"preview": "httprr trace v1\n1220 1886\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: la"
},
{
"path": "agents/testdata/TestOpenAIFunctionsAgentComplexCalculation.httprr",
"chars": 2991,
"preview": "httprr trace v1\n855 2111\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "agents/testdata/TestOpenAIFunctionsAgentWithHTTPRR.httprr",
"chars": 5230,
"preview": "httprr trace v1\n754 1852\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "callbacks/agent_final_stream.go",
"chars": 3712,
"preview": "package callbacks\n\nimport (\n\t\"context\"\n\t\"strings\"\n)\n\n// DefaultKeywords is map of the agents final out prefix keywords.\n"
},
{
"path": "callbacks/agent_final_stream_test.go",
"chars": 1383,
"preview": "package callbacks\n\nimport (\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n)\n\nfunc TestFilterFinalString(t *testing."
},
{
"path": "callbacks/callbacks.go",
"chars": 1342,
"preview": "package callbacks\n\nimport (\n\t\"context\"\n\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaingo/schema\"\n)\n\n// Ha"
},
{
"path": "callbacks/callbacks_unit_test.go",
"chars": 11661,
"preview": "package callbacks\n\nimport (\n\t\"context\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/assert\"\n\t\"github.com/stretchr/testify/m"
},
{
"path": "callbacks/combining.go",
"chars": 3006,
"preview": "package callbacks\n\nimport (\n\t\"context\"\n\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaingo/schema\"\n)\n\n// Co"
},
{
"path": "callbacks/doc.go",
"chars": 225,
"preview": "// Package callbacks includes a standard interface for hooking into various\n// stages of your LLM application. The packa"
},
{
"path": "callbacks/log.go",
"chars": 3630,
"preview": "//nolint:forbidigo\npackage callbacks\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github"
},
{
"path": "callbacks/log_stream.go",
"chars": 350,
"preview": "//nolint:forbidigo\npackage callbacks\n\nimport (\n\t\"context\"\n\t\"fmt\"\n)\n\n// StreamLogHandler is a callback handler that print"
},
{
"path": "callbacks/simple.go",
"chars": 1700,
"preview": "//nolint:forbidigo\npackage callbacks\n\nimport (\n\t\"context\"\n\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchain"
},
{
"path": "chains/api.go",
"chars": 4447,
"preview": "package chains\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t_ \"embed\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"regexp\"\n\n\t\"github.co"
},
{
"path": "chains/api_test.go",
"chars": 4742,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/tmc/langchaingo/internal/httprr\"\n\t\"g"
},
{
"path": "chains/chains.go",
"chars": 6430,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"sync\"\n\n\t\"github.com/tmc/langchaingo/callbacks\"\n\t\"github.com/tmc/langchaingo"
},
{
"path": "chains/chains_test.go",
"chars": 2745,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strconv\"\n\t\"sync\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/stretchr/testify/require\""
},
{
"path": "chains/chains_unit_test.go",
"chars": 15311,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/assert\"\n\t\"github.com/stretchr/te"
},
{
"path": "chains/constitution/constitutional.go",
"chars": 6400,
"preview": "package constitution\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"strings\"\n\n\t\"github.com/tmc/langchaingo/chains\"\n\t\"github.com/tmc/la"
},
{
"path": "chains/constitution/constitutional_test.go",
"chars": 2730,
"preview": "package constitution\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/"
},
{
"path": "chains/constitution/principles.go",
"chars": 18016,
"preview": "package constitution\n\n// nolint\nvar examplePrinciples = map[string]ConstitutionalPrinciple{\n\t\"harmful1\": {\n\t\tname: \"harm"
},
{
"path": "chains/constitution/prompts.go",
"chars": 10290,
"preview": "package constitution\n\nimport \"github.com/tmc/langchaingo/prompts\"\n\ntype constitutionalExample struct {\n\tinputPrompt "
},
{
"path": "chains/constitution/testdata/TestConstitutionalChain.httprr",
"chars": 9441,
"preview": "httprr trace v1\n297 1926\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/constitutional.go",
"chars": 34030,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"strings\"\n\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaing"
},
{
"path": "chains/constitutional_test.go",
"chars": 2138,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"g"
},
{
"path": "chains/conversation.go",
"chars": 840,
"preview": "package chains\n\nimport (\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaingo/outputparser\"\n\t\"github.com/tmc/"
},
{
"path": "chains/conversation_test.go",
"chars": 3804,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"os\"\n\t\"strings\"\n\t\"testing\"\n\n\tz \"github.com/getzep/zep-go\"\n\tzClient \"git"
},
{
"path": "chains/conversational_retrieval_qa.go",
"chars": 5562,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaingo/schema\"\n)\n\nc"
},
{
"path": "chains/conversational_retrieval_qa_test.go",
"chars": 12224,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"github.c"
},
{
"path": "chains/doc.go",
"chars": 152,
"preview": "// Package chains contains a standard interface for chains, a number of built-in chains and\n// functions for calling and"
},
{
"path": "chains/errors.go",
"chars": 2305,
"preview": "package chains\n\nimport \"errors\"\n\nvar (\n\t// ErrInvalidInputValues is returned if the input values to a chain is invalid.\n"
},
{
"path": "chains/llm.go",
"chars": 2465,
"preview": "package chains\n\nimport (\n\t\"context\"\n\n\t\"github.com/tmc/langchaingo/callbacks\"\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github"
},
{
"path": "chains/llm_azure_test.go",
"chars": 1491,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"os\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"gi"
},
{
"path": "chains/llm_math.go",
"chars": 2465,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t_ \"embed\"\n\t\"fmt\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github."
},
{
"path": "chains/llm_math_test.go",
"chars": 1093,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"github.c"
},
{
"path": "chains/llm_test.go",
"chars": 4107,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr/test"
},
{
"path": "chains/map_reduce.go",
"chars": 5668,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"maps\"\n\n\t\"github.com/tmc/langchaingo/memory\"\n\t\"github.com/tmc/langchaingo/sc"
},
{
"path": "chains/map_reduce_test.go",
"chars": 1336,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"github.com/tmc/langchaingo/prom"
},
{
"path": "chains/map_rerank_documents.go",
"chars": 5983,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"maps\"\n\t\"sort\"\n\t\"strconv\"\n\n\t\"github.com/tmc/langchaingo/memory\"\n\t\"github.com"
},
{
"path": "chains/map_rerank_documents_test.go",
"chars": 1762,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"github.com/tmc/langchaingo/prom"
},
{
"path": "chains/options.go",
"chars": 6704,
"preview": "package chains\n\nimport (\n\t\"context\"\n\n\t\"github.com/tmc/langchaingo/callbacks\"\n\t\"github.com/tmc/langchaingo/llms\"\n)\n\n// Ch"
},
{
"path": "chains/prompt_selector.go",
"chars": 843,
"preview": "package chains\n\nimport (\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaingo/prompts\"\n)\n\n// PromptSelector i"
},
{
"path": "chains/prompts/llm_api_url.txt",
"chars": 852,
"preview": "You are given the API Documentation:\n\n{{.api_docs}}\n\nYour task is to construct a full API JSON object based on the provi"
},
{
"path": "chains/prompts/llm_api_url_response.txt",
"chars": 288,
"preview": "\nHere is the response from the API:\n\n{{.api_response}}\n\nNow, summarize this response. Your summary should reflect the or"
},
{
"path": "chains/prompts/llm_math.txt",
"chars": 340,
"preview": "Translate a math problem into a expression that can be evaluated as Starlark.\nUse the output of running this code to ans"
},
{
"path": "chains/question_answering.go",
"chars": 5340,
"preview": "package chains\n\nimport (\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaingo/prompts\"\n)\n\n//nolint:lll\nconst "
},
{
"path": "chains/question_answering_test.go",
"chars": 2383,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"github.c"
},
{
"path": "chains/refine_documents.go",
"chars": 5107,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/tmc/langchaingo/memory\"\n\t\"github.com/tmc/langchaingo/prompts\"\n\t"
},
{
"path": "chains/retrieval_qa.go",
"chars": 2997,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaingo/memory\"\n\t\"gi"
},
{
"path": "chains/retrieval_qa_test.go",
"chars": 2140,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"github.c"
},
{
"path": "chains/sequential.go",
"chars": 6148,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/tmc/langchaingo/internal/maputil\"\n\t\"github"
},
{
"path": "chains/sequential_test.go",
"chars": 7243,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/assert\"\n\t\"github.com/stretchr/te"
},
{
"path": "chains/sql_database.go",
"chars": 5630,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaingo/m"
},
{
"path": "chains/sql_database_test.go",
"chars": 3993,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"github.com/tm"
},
{
"path": "chains/stuff_documents.go",
"chars": 2890,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/tmc/langchaingo/memory\"\n\t\"github.com/tmc/langchaingo/schema\"\n)\n"
},
{
"path": "chains/stuff_documents_test.go",
"chars": 2231,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"github.com/tmc/lang"
},
{
"path": "chains/summarization.go",
"chars": 1828,
"preview": "package chains\n\nimport (\n\t\"github.com/tmc/langchaingo/llms\"\n\t\"github.com/tmc/langchaingo/prompts\"\n)\n\nconst _stuffSummari"
},
{
"path": "chains/summarization_test.go",
"chars": 2182,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n\t\"github.com/tm"
},
{
"path": "chains/testdata/TestConstitutionalChainBasic.httprr",
"chars": 9532,
"preview": "httprr trace v1\n296 1975\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestConversation.httprr",
"chars": 4458,
"preview": "httprr trace v1\n567 1622\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestConversationWithChatLLM.httprr",
"chars": 6852,
"preview": "httprr trace v1\n567 1622\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestConversationWithZepMemory.httprr",
"chars": 16,
"preview": "httprr trace v1\n"
},
{
"path": "chains/testdata/TestLLMChain.httprr",
"chars": 1930,
"preview": "httprr trace v1\n314 1591\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestLLMChainAzure.httprr",
"chars": 16,
"preview": "httprr trace v1\n"
},
{
"path": "chains/testdata/TestLLMChainWithGoogleAI.httprr",
"chars": 2181,
"preview": "httprr trace v1\n787 1369\nPOST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?%"
},
{
"path": "chains/testdata/TestLLMMath.httprr",
"chars": 2348,
"preview": "httprr trace v1\n715 1608\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestMapReduceQA.httprr",
"chars": 34228,
"preview": "httprr trace v1\n830 1568\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestMapReduceSummarization.httprr",
"chars": 36603,
"preview": "httprr trace v1\n693 1723\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestRefineQA.httprr",
"chars": 34052,
"preview": "httprr trace v1\n866 1575\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestRefineSummarization.httprr",
"chars": 52191,
"preview": "httprr trace v1\n713 1711\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestRetrievalQA.httprr",
"chars": 2023,
"preview": "httprr trace v1\n359 1639\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestRetrievalQAFromLLM.httprr",
"chars": 2110,
"preview": "httprr trace v1\n516 1569\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestSQLDatabaseChain_Call.httprr",
"chars": 16,
"preview": "httprr trace v1\n"
},
{
"path": "chains/testdata/TestStuffDocuments.httprr",
"chars": 1906,
"preview": "httprr trace v1\n308 1573\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: lan"
},
{
"path": "chains/testdata/TestStuffSummarization.httprr",
"chars": 7136,
"preview": "httprr trace v1\n5083 2029\nPOST https://api.openai.com/v1/chat/completions HTTP/1.1\r\nHost: api.openai.com\r\nUser-Agent: la"
},
{
"path": "chains/testdata/mouse_story.txt",
"chars": 4680,
"preview": "Once upon a time, in a charming little village nestled deep within the enchanted forest, lived a small mouse named Olive"
},
{
"path": "chains/transform.go",
"chars": 1443,
"preview": "package chains\n\nimport (\n\t\"context\"\n\n\t\"github.com/tmc/langchaingo/memory\"\n\t\"github.com/tmc/langchaingo/schema\"\n)\n\n// Tra"
},
{
"path": "chains/transform_test.go",
"chars": 642,
"preview": "package chains\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n)\n\nfunc TestTransform(t *t"
},
{
"path": "doc.go",
"chars": 7338,
"preview": "// Package langchaingo provides a Go implementation of LangChain, a framework for building applications with Large Langu"
},
{
"path": "docs/.eslintrc.js",
"chars": 1160,
"preview": "/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found"
},
{
"path": "docs/.gitignore",
"chars": 265,
"preview": "# Dependencies\n/node_modules\n\n# Production\n/build\n\n# Generated files\n.docusaurus\n.cache-loader\ndocs/api\n\n# Misc\n.DS_Stor"
},
{
"path": "docs/.vale.ini",
"chars": 118,
"preview": "StylesPath = styles\nMinAlertLevel = suggestion\n\n[*.{md,mdx,txt,rst}]\nBasedOnStyles = langchaingo\n\n[formats]\nmdx = md\n\n"
},
{
"path": "docs/Makefile",
"chars": 1198,
"preview": ".PHONY: start\nstart:\n\tpnpm run start\n\n.PHONY: build\nbuild:\n\tpnpm run build\n\n.PHONY: lint\nlint:\n\tpnpm run lint\n\n.PHONY: l"
},
{
"path": "docs/README.md",
"chars": 1086,
"preview": "# Docs site\n\nThe documentation for this project is built using [Docusaurus](https://docusaurus.io/), a modern static web"
},
{
"path": "docs/babel.config.js",
"chars": 295,
"preview": "/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found"
},
{
"path": "docs/code-block-loader.js",
"chars": 674,
"preview": "/* eslint-disable prefer-template */\n/* eslint-disable no-param-reassign */\n// eslint-disable-next-line import/no-extran"
},
{
"path": "docs/docs/concepts/architecture.md",
"chars": 14922,
"preview": "# LangChainGo Architecture\n\nThis document explains LangChainGo's architecture and how it follows Go conventions.\n\n## Mod"
},
{
"path": "docs/docs/concepts/index.md",
"chars": 3494,
"preview": "# Concepts\n\nUnderstanding the fundamental concepts behind LangChainGo helps you build better applications.\n\n## Core arch"
},
{
"path": "docs/docs/contributing/documentation.md",
"chars": 6532,
"preview": "# Documentation contribution guide\n\nThis guide helps you contribute documentation to LangChainGo. We especially need hel"
},
{
"path": "docs/docs/contributing/index.md",
"chars": 4426,
"preview": "# Contributing to LangChainGo\n\nThank you for your interest in contributing to LangChainGo! This guide helps you get star"
},
{
"path": "docs/docs/getting-started/guide-chat.mdx",
"chars": 810,
"preview": "---\nsidebar_position: 3\ndraft: true\n---\n\n# Unfinished quickstart, using chat models\n\nChat models are a variation on lang"
},
{
"path": "docs/docs/getting-started/guide-mistral.mdx",
"chars": 2203,
"preview": "---\nsidebar_position: 3\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport ExampleMistral from \"@examples/mistral-com"
},
{
"path": "docs/docs/getting-started/guide-ollama.mdx",
"chars": 1864,
"preview": "---\nsidebar_position: 1\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport ExampleOllama from \"@examples/ollama-compl"
},
{
"path": "docs/docs/getting-started/guide-openai.mdx",
"chars": 1819,
"preview": "---\nsidebar_position: 2\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport ExampleOpenAI from \"@examples/openai-compl"
},
{
"path": "docs/docs/how-to/configure-llm-providers.md",
"chars": 6508,
"preview": "# How to configure different LLM providers\n\nThis guide shows you how to configure and use different LLM providers with L"
},
{
"path": "docs/docs/how-to/index.md",
"chars": 1981,
"preview": "# How-to guides\n\nThese how-to guides answer \"How do I...?\" questions with practical solutions for specific problems.\n\n**"
},
{
"path": "docs/docs/index.md",
"chars": 3133,
"preview": "# Welcome to LangChainGo\n\n\nLangChainGo is the [Go Programming Language](https://go.dev/) port/fork of\n[LangChain](https:"
},
{
"path": "docs/docs/modules/agents/agents/index.mdx",
"chars": 237,
"preview": "---\nhide_table_of_contents: true\nsidebar_position: 1\n---\n\nimport DocCardList from \"@theme/DocCardList\";\n\n# Agents\n\n:::in"
},
{
"path": "docs/docs/modules/agents/executor/getting-started.mdx",
"chars": 1399,
"preview": "---\nsidebar_label: Getting Started\nhide_table_of_contents: true\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport Ex"
},
{
"path": "docs/docs/modules/agents/executor/index.mdx",
"chars": 700,
"preview": "---\nhide_table_of_contents: true\nsidebar_position: 2\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport Example from "
},
{
"path": "docs/docs/modules/agents/index.mdx",
"chars": 3365,
"preview": "---\nsidebar_position: 5\nhide_table_of_contents: true\n---\n\nimport DocCardList from \"@theme/DocCardList\";\n\n# Agents\n\n:::in"
},
{
"path": "docs/docs/modules/agents/tools/index.mdx",
"chars": 194,
"preview": "---\nhide_table_of_contents: true\nsidebar_position: 3\n---\n\nimport DocCardList from \"@theme/DocCardList\";\n\n# Tools\n\n:::inf"
},
{
"path": "docs/docs/modules/chains/index.mdx",
"chars": 3604,
"preview": "---\nhide_table_of_contents: true\nsidebar_label: Chains\nsidebar_position: 3\n---\n\nimport DocCardList from \"@theme/DocCardL"
},
{
"path": "docs/docs/modules/chains/llm_chain.mdx",
"chars": 797,
"preview": "---\nsidebar_label: LLM Chain\nsidebar_position: 1\ndraft: true\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport Examp"
},
{
"path": "docs/docs/modules/data_connection/document_loaders/index.mdx",
"chars": 1017,
"preview": "---\nsidebar_label: Document Loaders\nsidebar_position: 1\ndraft: true\n---\n\nimport DocCardList from \"@theme/DocCardList\";\n\n"
},
{
"path": "docs/docs/modules/data_connection/index.mdx",
"chars": 823,
"preview": "---\nsidebar_position: 2\nhide_table_of_contents: true\ndraft: true\n---\n\nimport DocCardList from \"@theme/DocCardList\";\n\n# D"
},
{
"path": "docs/docs/modules/data_connection/retrievers/index.mdx",
"chars": 2660,
"preview": "---\nhide_table_of_contents: true\nsidebar_position: 4\n---\n\nimport DocCardList from \"@theme/DocCardList\";\n\n# Retrievers\n\n:"
},
{
"path": "docs/docs/modules/data_connection/text_splitters/examples/index.mdx",
"chars": 1192,
"preview": "---\nsidebar_label: Examples\n---\n\nimport DocCardList from \"@theme/DocCardList\";\n\n# Text Splitters: Examples\n\nSplitters ar"
},
{
"path": "docs/docs/modules/data_connection/text_splitters/index.mdx",
"chars": 837,
"preview": "---\nsidebar_label: Text Splitters\nhide_table_of_contents: true\nsidebar_position: 2\n---\n\nimport DocCardList from \"@theme/"
},
{
"path": "docs/docs/modules/data_connection/vector_stores/index.mdx",
"chars": 601,
"preview": "---\nsidebar_label: \"Vector Stores\"\nsidebar_position: 3\ndraft: true\n---\n\nimport React from \"react\";\nimport DocCardList fr"
},
{
"path": "docs/docs/modules/data_connection/vector_stores/pgvector.mdx",
"chars": 2185,
"preview": "---\nsidebar_label: pgvector\nsidebar_position: 1\ndraft: true\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport Exampl"
},
{
"path": "docs/docs/modules/memory/examples/index.mdx",
"chars": 116,
"preview": "---\nsidebar_label: Examples\n---\n\nimport DocCardList from \"@theme/DocCardList\";\n\n# Examples: Memory\n\n<DocCardList />\n"
},
{
"path": "docs/docs/modules/memory/index.mdx",
"chars": 3131,
"preview": "---\nsidebar_label: Memory\nsidebar_position: 4\n---\n\nimport DocCardList from \"@theme/DocCardList\";\n\n# Memory\n\n:::info\n[Con"
},
{
"path": "docs/docs/modules/model_io/index.mdx",
"chars": 665,
"preview": "---\nsidebar_position: 1\nhide_table_of_contents: true\nsidebar_label: Model I/O\ndraft: true\n---\n\nimport DocCardList from \""
},
{
"path": "docs/docs/modules/model_io/models/chat/index.mdx",
"chars": 1434,
"preview": "---\nsidebar_position: 2\nhide_table_of_contents: true\nsidebar_label: Chat Models\n---\n\nimport CodeBlock from \"@theme/CodeB"
},
{
"path": "docs/docs/modules/model_io/models/chat/integrations.mdx",
"chars": 818,
"preview": "---\nsidebar_position: 3\nsidebar_label: Integrations\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\n\n# Integrations: Chat"
},
{
"path": "docs/docs/modules/model_io/models/embeddings/index.mdx",
"chars": 655,
"preview": "---\nsidebar_position: 3 \nhide_table_of_contents: true\nsidebar_label: Embeddings\n---\n\nimport DocCardList from \"@theme/Doc"
},
{
"path": "docs/docs/modules/model_io/models/embeddings/integrations.mdx",
"chars": 847,
"preview": "---\nsidebar_position: 3\nsidebar_label: Integrations\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\n\n# Integrations: Embe"
},
{
"path": "docs/docs/modules/model_io/models/index.mdx",
"chars": 2361,
"preview": "---\nsidebar_position: 2\nhide_table_of_contents: true\nsidebar_label: Models\n---\n\nimport DocCardList from \"@theme/DocCardL"
},
{
"path": "docs/docs/modules/model_io/models/llms/Integrations/fake.mdx",
"chars": 2591,
"preview": "---\nsidebar_label: Fake LLM\n---\n\n# Fake LLM\n\n## Overview\n\nThis documentation provides an overview of the `fake` package,"
},
{
"path": "docs/docs/modules/model_io/models/llms/Integrations/groq.mdx",
"chars": 1294,
"preview": "---\nsidebar_label: Groq\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport ExampleGroq from \"@examples/groq-completio"
},
{
"path": "docs/docs/modules/model_io/models/llms/Integrations/huggingface.mdx",
"chars": 1079,
"preview": "---\nsidebar_label: Hugging Face\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport ExampleHuggingFace from \"@examples"
},
{
"path": "docs/docs/modules/model_io/models/llms/Integrations/llamafile.mdx",
"chars": 395,
"preview": "---\nsidebar_label: Llamafile\n---\nimport CodeBlock from \"@theme/CodeBlock\";\nimport ExampleLlamafile from \"@examples/llama"
},
{
"path": "docs/docs/modules/model_io/models/llms/Integrations/local.mdx",
"chars": 223,
"preview": "---\nsidebar_label: Local\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport LocalExample from \"@examples/local-llm-ex"
},
{
"path": "docs/docs/modules/model_io/models/llms/Integrations/mistral.mdx",
"chars": 1631,
"preview": "---\nsidebar_label: Mistral\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport ExampleMistral from \"@examples/mistral-"
},
{
"path": "docs/docs/modules/model_io/models/llms/Integrations/openai.mdx",
"chars": 697,
"preview": "---\nsidebar_label: OpenAI\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport ExampleOpenAI from \"@examples/openai-com"
},
{
"path": "docs/docs/modules/model_io/models/llms/Integrations/vertexai.mdx",
"chars": 462,
"preview": "---\nsidebar_label: Vertex AI\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport ExampleVertexAICompletion from \"@exam"
},
{
"path": "docs/docs/modules/model_io/models/llms/Integrations/watsonx.mdx",
"chars": 1003,
"preview": "---\nsidebar_label: watsonx\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\nimport WatsonxExample from \"@examples/watsonx-"
},
{
"path": "docs/docs/modules/model_io/models/llms/index.mdx",
"chars": 1730,
"preview": "---\nsidebar_position: 1\nhide_table_of_contents: true\nsidebar_label: LLMs\n---\n\nimport CodeBlock from \"@theme/CodeBlock\";\n"
},
{
"path": "docs/docs/modules/model_io/output_parsers/index.mdx",
"chars": 1001,
"preview": "---\nsidebar_label: Output Parsers\nsidebar_position: 3\n---\n\n# Output Parsers\n\n:::info\n[Conceptual Guide](https://python.l"
},
{
"path": "docs/docs/modules/model_io/prompts/index.mdx",
"chars": 2684,
"preview": "---\nsidebar_position: 1\nhide_table_of_contents: true\nsidebar_label: Prompts\n---\n\nimport React from \"react\";\nimport DocCa"
},
{
"path": "docs/docs/modules/model_io/prompts/prompt_templates/index.mdx",
"chars": 7113,
"preview": "---\nhide_table_of_contents: true\nsidebar_label: Prompt templates\nsidebar_position: 1\n---\n\nimport CodeBlock from \"@theme/"
},
{
"path": "docs/docs/modules/model_io/prompts/prompt_templates/partial_values.mdx",
"chars": 1925,
"preview": "---\nsidebar_label: Partial values\n---\n\n# Partial values\n\nIt can often make sense to \"partial\" a prompt template - passin"
},
{
"path": "docs/docs/tutorials/basic-chat-app.md",
"chars": 5822,
"preview": "# Building a Basic Chat Application\n\nThis tutorial will guide you through building a simple chat application using LangC"
},
{
"path": "docs/docs/tutorials/code-reviewer.md",
"chars": 10407,
"preview": "# Building an AI code reviewer\n\nCreate an intelligent code review assistant that analyzes Go code for bugs, style issues"
},
{
"path": "docs/docs/tutorials/index.md",
"chars": 1852,
"preview": "# Tutorials\n\nWelcome to the LangChainGo tutorials! These step-by-step guides help you build complete applications using "
},
{
"path": "docs/docs/tutorials/log-analyzer.md",
"chars": 20863,
"preview": "# Building an intelligent log analyzer\n\nCreate an AI-powered log analysis tool that identifies patterns, anomalies, and "
},
{
"path": "docs/docs/tutorials/smart-documentation.md",
"chars": 33323,
"preview": "# Building smart documentation generator\n\nCreate an AI-powered tool that automatically generates and maintains technical"
},
{
"path": "docs/docusaurus.config.js",
"chars": 5501,
"preview": "/* eslint-disable global-require,import/no-extraneous-dependencies */\n\n// @ts-check\n// Note: type annotations allow type"
},
{
"path": "docs/go.mod",
"chars": 160,
"preview": "module search-indexer\n\ngo 1.21\n\nrequire (\n\tgithub.com/yuin/goldmark v1.7.8\n\tgithub.com/yuin/goldmark-meta v1.1.0\n)\n\nrequ"
},
{
"path": "docs/go.sum",
"chars": 704,
"preview": "github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=\ngithub.com/yuin/goldmark v1.7.8/go.mod h"
},
{
"path": "docs/package.json",
"chars": 2085,
"preview": "{\n \"name\": \"docs\",\n \"version\": \"0.0.0\",\n \"private\": true,\n \"scripts\": {\n \"docusaurus\": \"docusaurus\",\n \"start\":"
},
{
"path": "docs/parity_matrix.md",
"chars": 13887,
"preview": "# LangChainGo Features\n\nThis page provides a list of features and their status indicators for LangChainGo, a natural lan"
},
{
"path": "docs/search-indexer.go",
"chars": 17996,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"flag\"\n\t\"fmt\"\n\t\"go/ast\"\n\t\"go/doc\"\n\t\"go/parser\"\n\t\"go/token\"\n\t\"io/fs\"\n\t\"log\"\n\t\"os"
},
{
"path": "docs/sidebars.js",
"chars": 2547,
"preview": "/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found"
},
{
"path": "docs/src/css/custom.css",
"chars": 6704,
"preview": "/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found"
},
{
"path": "docs/src/pages/index.js",
"chars": 350,
"preview": "/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found"
},
{
"path": "docs/src/theme/CodeBlock/index.js",
"chars": 411,
"preview": "/* eslint-disable react/jsx-props-no-spreading */\nimport React from \"react\";\nimport CodeBlock from \"@theme-original/Code"
},
{
"path": "docs/src/theme/SearchBar/SearchBar.css",
"chars": 2605,
"preview": ".navbar__search {\n position: relative;\n margin-left: 16px;\n}\n\n.navbar__search-input {\n width: 200px;\n padding: 6px 1"
},
{
"path": "docs/src/theme/SearchBar/index.js",
"chars": 7699,
"preview": "import React, { useState, useEffect, useRef } from 'react';\nimport useDocusaurusContext from '@docusaurus/useDocusaurusC"
},
{
"path": "docs/static/.nojekyll",
"chars": 0,
"preview": ""
},
{
"path": "docs/styles/langchaingo/ActiveVoice.yml",
"chars": 280,
"preview": "extends: existence\nmessage: \"Use active voice: '%s'\"\nlevel: warning\nignorecase: true\ntokens:\n - should be configured\n "
},
{
"path": "docs/styles/langchaingo/Clarity.yml",
"chars": 193,
"preview": "extends: existence\nmessage: \"Be more specific than '%s'\"\nlevel: suggestion\ntokens:\n - 'easy'\n - 'simple'\n - 'just'\n "
},
{
"path": "docs/styles/langchaingo/CodeBlockLanguage.yml",
"chars": 149,
"preview": "extends: existence\nmessage: \"Specify language for code blocks (use ```go, ```bash, etc.)\"\nlevel: error\nscope: raw\ntokens"
},
{
"path": "docs/styles/langchaingo/ConsistentLists.yml",
"chars": 129,
"preview": "extends: consistency\nmessage: \"Inconsistent list punctuation\"\nlevel: warning\nscope: list\neither:\n ':': ':'\n '.': '.'\n "
},
{
"path": "docs/styles/langchaingo/DirectLanguage.yml",
"chars": 325,
"preview": "extends: existence\nmessage: \"Avoid flowery or marketing language\"\nlevel: error\nignorecase: true\ntokens:\n - amazing\n - "
},
{
"path": "docs/styles/langchaingo/ErrorHandling.yml",
"chars": 136,
"preview": "extends: existence\nmessage: \"Include error handling in Go examples\"\nlevel: warning\nscope: raw\ntokens:\n - ':= .+\\(\\)$'\n "
},
{
"path": "docs/styles/langchaingo/HardcodedSecrets.yml",
"chars": 242,
"preview": "extends: existence\nmessage: \"Don't include hardcoded API keys or secrets\"\nlevel: error\ntokens:\n - 'sk-[a-zA-Z0-9]{48}'\n"
},
{
"path": "docs/styles/langchaingo/Headers.yml",
"chars": 1136,
"preview": "extends: capitalization\nmessage: \"Use sentence case for headers, not Title Case\"\nlevel: suggestion\nmatch: $heading\nstyle"
},
{
"path": "docs/styles/langchaingo/IncompleteExamples.yml",
"chars": 228,
"preview": "extends: existence\nmessage: \"Avoid incomplete code examples (use complete, runnable code)\"\nlevel: warning\ntokens:\n - '/"
},
{
"path": "docs/styles/langchaingo/NoEmojis.yml",
"chars": 207,
"preview": "extends: existence\nmessage: \"Don't use emojis in documentation\"\nlevel: error\ntokens:\n - '😀'\n - '😃'\n - '😄'\n - '😁'\n -"
},
{
"path": "docs/styles/langchaingo/PresentTense.yml",
"chars": 307,
"preview": "extends: substitution\nmessage: \"Use present tense: '%s' instead of '%s'\"\nlevel: warning\nswap:\n 'will return': 'returns'"
},
{
"path": "docs/styles/langchaingo/Pronouns.yml",
"chars": 228,
"preview": "extends: existence\nmessage: \"Use 'you/your' to address readers directly\"\nlevel: suggestion\nscope: sentence\ntokens:\n - '"
},
{
"path": "docs/styles/langchaingo/Readability.yml",
"chars": 146,
"preview": "extends: readability\nmessage: \"Try to keep sentences shorter and clearer\"\nlevel: suggestion\ngrade: 9\nmetrics:\n - Flesch"
},
{
"path": "docs/styles/langchaingo/Spelling.yml",
"chars": 103,
"preview": "extends: spelling\nmessage: \"Check spelling of '%s'\"\nlevel: warning\nignore:\n - langchaingo/ignore.txt\n\n"
},
{
"path": "docs/styles/langchaingo/Terminology.yml",
"chars": 352,
"preview": "extends: substitution\nmessage: \"Use '%s' instead of '%s' for consistency\"\nlevel: warning\nignorecase: true\nswap:\n 'click"
}
]
// ... and 948 more files (download for full content)
About this extraction
This page contains the full source code of the tmc/langchaingo GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 1148 files (7.7 MB), approximately 2.1M tokens, and a symbol index with 4823 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.