Skip to content

Commit

Permalink
Merge pull request askrella#210 from juliandaz11/master
Browse files Browse the repository at this point in the history
Sending text and audio at the same time
  • Loading branch information
navopw authored May 9, 2023
2 parents 6b0a0ae + 321b5cf commit 061bffe
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# Get your key here: https://platform.openai.com/account/api-keys
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
HUGGINGFACE_API_TOKEN=hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

# In case you run into ratelimit on a single organization token, you might setting up multiple API keys here
# Example:
Expand Down Expand Up @@ -95,4 +96,4 @@ AWS_POLLY_VOICE_ENGINE=standard


# LangChain Tool Config https://js.langchain.com/docs/modules/agents/tools/
SERPAPI_API_KEY=xxxxxxxxx
SERPAPI_API_KEY=xxxxxxxxx
15 changes: 9 additions & 6 deletions docs/pages/langchain.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# LangChain

## About

Use this handler to allow GPT to interact with other sources of data, ie. the internet, or different mediums like pdfs and images. Ideally the user doesn't have to differentiate between GPT instances that can and cannot use external data sources, but we'll keep them separate for ease of implementation for now.

## Example

In the following example, GPT uses `SerpAPI` as a tool to access Google Search API. You can use `RequestsGetTool` and parse the HTML if you don't have a [SerpAPI](https://serpapi.com/) API key.
>!lang nba game april 11st 2023
>

> !lang nba game april 11st 2023
>
> // Uses SerpAPI or RequestsGetTool to access the search engine, parse results in either JSON or HTML, and have GPT interpret the best answer for the prompt.
>"The result of the NBA games on April 11st 2023 is Minnesota Timberwolves vs Los Angeles Lakers"
> "The result of the NBA games on April 11st 2023 is Minnesota Timberwolves vs Los Angeles Lakers"
## Tools

Abstractions for GPT to interact with to interact with external data sources. For example, both `RequestGetTools` and `SerpAPI` allows GPT to access the internet.

See other tools in the LangChain [Tools section](https://js.langchain.com/docs/modules/agents/tools/).


## References
* [LangChain in JS](https://js.langchain.com/docs/)
* [LangChain in Python](https://python.langchain.com/en/latest/index.html)

- [LangChain in JS](https://js.langchain.com/docs/)
- [LangChain in Python](https://python.langchain.com/en/latest/index.html)
2 changes: 2 additions & 0 deletions src/handlers/gpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const handleMessageGPT = async (message: Message, prompt: string) => {
// TTS reply (Default: disabled)
if (getConfig("tts", "enabled")) {
sendVoiceMessageReply(message, response);
// Default: Text reply
message.reply(response);
return;
}

Expand Down
1 change: 0 additions & 1 deletion src/handlers/langchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const browserAgent = new BrowserAgentProvider();
// TODO add conversation ID to build a chat history
const handleMessageLangChain = async (message: Message, prompt: string) => {
try {

const start = Date.now();
const output = await browserAgent.fetch(prompt);
const end = Date.now() - start;
Expand Down
5 changes: 2 additions & 3 deletions src/handlers/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ async function handleIncomingMessage(message: Message) {
return;
}
}

// Ignore groupchats if disabled
if ((await message.getChat()).isGroup && !config.groupchatsEnabled) return;
if ((await message.getChat()).isGroup && !config.groupchatsEnabled) return;

const selfNotedMessage = message.fromMe && message.hasQuotedMsg === false && message.from === message.to;
const whitelistedPhoneNumbers = getConfig("general", "whitelist");
Expand Down Expand Up @@ -138,7 +138,6 @@ async function handleIncomingMessage(message: Message) {
return;
}


// GPT (!lang <prompt>)
if (startsWithIgnoreCase(messageString, config.langChainPrefix)) {
const prompt = messageString.substring(config.langChainPrefix.length + 1);
Expand Down

0 comments on commit 061bffe

Please sign in to comment.