Giter VIP home page Giter VIP logo

assistantcontextwindow's Introduction

Assistant Manager Builder Mark 0.0.1

[email protected] (email me if you find issues) Thanks to following for their tools

This is an initial version that demonstrates the "Thread Context Window" in action. User prompts and Assistant answers are added to the Thread Messages. None are deleted When we get a new thread we start all over again with only the system prompt repeated.

You can create an Assistant by giving a name. It checks if that name is in use and if so returns the assistant_id of that previous version. The assistant is given a basic System Prompt - You are a helpful assistant It also creates a new thread to run on. You then create a user: Message and next hit Run to run the thread with all messages on it including the new one. You then need to check the Status of the Run (completed, in_progress, awaiting_action) Finally you can get all messages on the thread.

References developersdigest/OpenAI_Function_Toolkit_And_Library

Reference btg5679/javascript-openai-web-crawler

We are using GitHub Codespaces to develop this. So when you fork you may need to change the .devcontainer/devcontainer.json to point to your fork. We are using NPM and Node so run "npm install" to install all the dependencies. In the future you may need to modify the libraries to use the latest eg puppeteer Similarly the openai API is changing fairly rapidly so monitor any deprecations of models For example a number were deprecated on Jan 4, 2024

Note on Scope

At present we only allow 1 active Assistant Note that to attach a file to an Assistant it must have either "retrieve" or "code_interpret" capabilities. At present we create every Assistant with both capabilities.

Tools: To add functions as tools put them into the "function" sub-directory

All functions in that directory will be loaded to the assistant. We use the style proposed by developersdigest/OpenAI_Function_Toolkit_And_Library You must have both "execute" and "details" variables This allows us to dynamically call functions that the LLM requests

Keys

First get Keys for OPEANAI_API_KEY and put it in GitHub Secrets for Codespaces To run the OpenWeather Tool you'll need WEATHER_API_KEY

Typical Run

A typical run first run the web server "node server.js". This should popup a browser window with the Assistant on port 3000 or 4000. There are rows of buttons.

Assistants

The first row is for the Assistant. Click Create Assistant to create a new Assistant (after the first time you can just use List to load an existing Assistant) You should see the Assistant_ID in the output

Files

For now don't load a file. You can load a file later. Its a two step process. First Create and then Attach to an Assistant.

Threads

Next create a Thread - you should see the Thread_ID in the output. We use a single thread but you can run more. We place messages onto a thread and responses are added to the thread.

Tools

Now go to Add Tools which will add all the Tools in the function directory + the Retrieval and Code Interpret tools

Messages

Now create a Message. Try this one "What is the weather in Boston?"

Runs

Now create a Run which will send the the Message on the Thread to OpenAI.

Runs Get Status

Get Status polls every 1/2 second to see if GPT is finished. It also executes any requests from the GPT to run tools. You can see in the Terminal Window when it is running tools locally. Now click Get Message to retrieve any messages on the Thread. You should see the answer to the question.

Debug

At present I have a lot of debug messages to the console. I will remove them in the future.

GPT Output (Green Area)

Also there are messages from GPT that are outputted at the botthom of the page in the green area. I give examples of functions you might want to load such as "take screenshot of a web site" OpenWeather function - try "What is the weather in Boston?" The openweather function is a simple function that uses the openweather API to return the weather for a city. It is a simple example of how to use an API. You will need a key from openweather WEATHER_API_KEY to use it. You can get one for free at

Functions/Tools

The most sophisticated is the crawlDomain function which will crawl the web to find answers to questions. Try "Crawl the Lunarmail.io web site and answer the question "What products does Lunarmail offer?" Its modified from btg5679/javascript-openai-web-crawler It will answer question if possible from stored embeddings. If not it will crawl the web to find the answer. It makes use of RAG to embed the question ## ## tokens and compare them to the embeddings of the web pages. It uses GPT to figure out "Key" tokens in the question. ## It will then use the best match to answer the question. If it can't find an answer it will use GPT to generate an ## answer. It will then store the answer in the database for future use. You may want to delete crawled_urls.csv and contents.csv to start fresh.

assistantcontextwindow's People

Contributors

johntango avatar jrw0mitedu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.