Skip to content

(EAI-930): Retrieval tool call (feature branch) #763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 11, 2025
Merged

Conversation

mongodben
Copy link
Collaborator

@mongodben mongodben commented Jun 5, 2025

Jira: https://jira.mongodb.org/browse/EAI-930

Changes

  • Refactor chatbot retrieval system to use tool calling
  • Upgrade chatbot to use GPT-4.1
  • Deprecate framework npm packages
    • mongodb-chatbot-server
    • mongodb-rag-core
    • mongodb-rag-ingest
  • Publish new docs

Notes

mongodben and others added 4 commits May 27, 2025 12:50
* refactor GenerateRespose

* Clean up imports

* consolidate generate user prompt to the legacy file

* update test config imports

* Fix broken tests

* (EAI-989): Refactor verified answers to wrap `GenerateResponse` (#688)

verified answer generate response

Co-authored-by: Ben Perlmutter <[email protected]>

* handle streaming

* separate generateresponse

* typo fix

---------

Co-authored-by: Ben Perlmutter <[email protected]>
* refactor GenerateRespose

* Clean up imports

* consolidate generate user prompt to the legacy file

* update test config imports

* Fix broken tests

* get started

* nominally working generate res w/ search

* small refactors

* aint pretty but fully functional

* hacky if more functional

* more hack

* tools

* functional if not pretty

* Add processing

* working tool calling

* making progress

* keepin on

* Clean config

* working e2e

* update model version

* Remove no longer used stuff

* decouple search results for references and whats shown to model

* fix scripts build errs

* fix broken tests

* update default ref links

* fix broken tests

* Apply suggestions from code review

Co-authored-by: Nick Larew <[email protected]>

* revert default reference links

* adding missing test

---------

Co-authored-by: Ben Perlmutter <[email protected]>
Co-authored-by: Nick Larew <[email protected]>
* refactor GenerateRespose

* Clean up imports

* consolidate generate user prompt to the legacy file

* update test config imports

* Fix broken tests

* get started

* nominally working generate res w/ search

* small refactors

* aint pretty but fully functional

* hacky if more functional

* more hack

* tools

* functional if not pretty

* Add processing

* working tool calling

* making progress

* keepin on

* Clean config

* working e2e

* update model version

* Remove no longer used stuff

* decouple search results for references and whats shown to model

* fix scripts build errs

* remove ChatLlm

* lite fixes

* Remove stub

---------

Co-authored-by: Ben Perlmutter <[email protected]>
* refactor GenerateRespose

* Clean up imports

* consolidate generate user prompt to the legacy file

* update test config imports

* Fix broken tests

* get started

* nominally working generate res w/ search

* small refactors

* aint pretty but fully functional

* hacky if more functional

* more hack

* tools

* functional if not pretty

* Add processing

* working tool calling

* making progress

* keepin on

* Clean config

* working e2e

* update model version

* Remove no longer used stuff

* decouple search results for references and whats shown to model

* fix scripts build errs

* fix broken tests

* deprecation

* build out docs following last week convo

* clean up spec + contact

* fix merge funk

* docs updates

---------

Co-authored-by: Ben Perlmutter <[email protected]>
@mongodben mongodben changed the title (EAI-930): Retrieval tool call (EAI-930): Retrieval tool call (feature branch) Jun 5, 2025
mongodben and others added 5 commits June 6, 2025 16:28
* update to fix broken test

* Update packages/ingest-mongodb-public/src/sources/snooty/snootyAstToOpenApiSpec.ts

---------

Co-authored-by: Ben Perlmutter <[email protected]>
* refactor GenerateRespose

* Clean up imports

* consolidate generate user prompt to the legacy file

* update test config imports

* Fix broken tests

* get started

* nominally working generate res w/ search

* small refactors

* aint pretty but fully functional

* hacky if more functional

* more hack

* tools

* functional if not pretty

* Add processing

* working tool calling

* making progress

* keepin on

* Clean config

* working e2e

* update model version

* Remove no longer used stuff

* decouple search results for references and whats shown to model

* fix scripts build errs

* fix broken tests

* update default ref links

* fix broken tests

* input guardrail refactor

* guardrail works well

* simpler validity metric

* add guardrail to server

* add next step todo

* llm refusal msg

* remove TODO comment

* merge fix

* fix unnec changes

* NL feedback

---------

Co-authored-by: Ben Perlmutter <[email protected]>
* refactor GenerateRespose

* Clean up imports

* consolidate generate user prompt to the legacy file

* update test config imports

* Fix broken tests

* get started

* nominally working generate res w/ search

* small refactors

* aint pretty but fully functional

* hacky if more functional

* more hack

* tools

* functional if not pretty

* Add processing

* working tool calling

* making progress

* keepin on

* Clean config

* working e2e

* update model version

* Remove no longer used stuff

* decouple search results for references and whats shown to model

* fix scripts build errs

* fix broken tests

* update default ref links

* fix broken tests

* input guardrail refactor

* guardrail works well

* simpler validity metric

* add guardrail to server

* add next step todo

* llm refusal msg

* remove TODO comment

* evals on new architecture

* Get urls in a way that supports verified answers

* dont eval on retrieved elems if no context

* Cleaner handling

* update trace handling

* update trace handling

* undo git funk

* handle undefined case

* Fix tracing test

---------

Co-authored-by: Ben Perlmutter <[email protected]>
@mongodben mongodben marked this pull request as ready for review June 11, 2025 17:03
@nlarew
Copy link
Collaborator

nlarew commented Jun 11, 2025

I think something broke with follow up questions - this works on prod but not locally on the feature branch:

PROD

USER: how to insertone nodejs
ASST: <... gives a good answer ...>
USER: show me in python?
ASST: <... gives a good answer in python ...>

FEATURE BRANCH

USER: how to insertone nodejs
ASST: <... gives a good answer ...>
USER: show me in python?
ASST: I'm sorry, I do not know how to answer that question. Please try to rephrase your query.

Conversation ID (in dev): 6849b9bce143f2ae905528e6

@nlarew
Copy link
Collaborator

nlarew commented Jun 11, 2025

Issue with logging - each line of the response is getting a separate log line.

Also note that this is logging the first message "Final result" after I sent the second message

chatbot-server-mongodb-public: {"level":"info","message":"Request info:\nUser message: show me in python?\nStream: true\nIP: ::1\nConversationId: 6849bad4e143f2ae905528f5","reqId":"6849bae0e143f2ae905528fa"}
chatbot-server-mongodb-public: Name matches found: []
chatbot-server-mongodb-public: Final result: To insert a single document into MongoDB using Node.js, use the insertOne() method from the MongoDB Node.js driver. Here's a simple example:
chatbot-server-mongodb-public: ```javascript
chatbot-server-mongodb-public: import { MongoClient } from "mongodb";
chatbot-server-mongodb-public: // Replace with your MongoDB connection string
chatbot-server-mongodb-public: const uri = "<connection string uri>";
chatbot-server-mongodb-public: const client = new MongoClient(uri);
chatbot-server-mongodb-public: async function run() {
chatbot-server-mongodb-public:   try {
chatbot-server-mongodb-public:     // Connect to the database and collection
chatbot-server-mongodb-public:     const database = client.db("myDB");
chatbot-server-mongodb-public:     const collection = database.collection("pizzaMenu");
chatbot-server-mongodb-public:     // Document to insert
chatbot-server-mongodb-public:     const doc = { name: "Neapolitan pizza", shape: "round" };
chatbot-server-mongodb-public:     // Insert the document
chatbot-server-mongodb-public:     const result = await collection.insertOne(doc);
chatbot-server-mongodb-public:     // Output the inserted document's _id
chatbot-server-mongodb-public:     console.log(`A document was inserted with the _id: ${result.insertedId}`);
chatbot-server-mongodb-public:   } finally {
chatbot-server-mongodb-public:     await client.close();
chatbot-server-mongodb-public:   }
chatbot-server-mongodb-public: }
chatbot-server-mongodb-public: run().catch(console.dir);
chatbot-server-mongodb-public: ```
chatbot-server-mongodb-public: - Replace <connection string uri> with your MongoDB connection string.
chatbot-server-mongodb-public: - The insertOne() method returns an object containing the inserted document's _id.
chatbot-server-mongodb-public: Let me know if you need more details or help with setup!
chatbot-server-mongodb-public: {"level":"info","message":"SSE connection was closed."}

@mongodben mongodben merged commit 6c5b4b5 into main Jun 11, 2025
1 check was pending
@mongodben mongodben deleted the retrieval_tool_call branch June 11, 2025 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants