From b753c4cffcaadd0597134c25c0530f9b2a7a01e7 Mon Sep 17 00:00:00 2001 From: ogzhanolguncu Date: Tue, 25 Jun 2024 11:36:49 +0300 Subject: [PATCH 1/2] docs: update readme --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 123a24e9..48db196b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ ![npm (scoped)](https://img.shields.io/npm/v/@upstash/qstash) -> [!NOTE] -> **This project is in GA Stage.** +> [!NOTE] > **This project is in GA Stage.** > > The Upstash Professional Support fully covers this project. It receives regular updates, and bug fixes. > The Upstash team is committed to maintaining and improving its functionality. @@ -102,6 +101,60 @@ const isValid = await r.verify({ }) ``` +### Publishing a message to Open AI or any Open AI Compatible LLM + +No need for complicated setup your LLM request. We'll call LLM and schedule it for your serverless needs. + +```ts +import { Client } from "@upstash/qstash"; + +const c = new Client({ + token: "", +}); + +const result = await client.publishJSON({ + llmProvider: "openai", // We currently support open-ai and together-ai, but QStash will work with any OpenAI compatible API + llmToken: "YOUR_TOKEN", + url: "OPEN_AI_COMPATIBLE_BASE_URL", + body: { + model: "gpt-3.5-turbo", + messages: [ + { + role: "user", + content: "Where is the capital of Turkey?", + }, + ], + }, + callback: "https://oz.requestcatcher.com/", +}); +``` + +### Chatting with your favorite LLM + +You can easily start streaming Upstash, OpenAI or TogetherAI responses from your favorite framework(Next.js) or library + +```ts +const response = await client.chat().create({ + provider: "upstash", // Optionally, provider: "openai" + model: "meta-llama/Meta-Llama-3-8B-Instruct", // Optionally, model: "gpt-3.5-turbo", + llmToken: process.env.OPENAI_API_KEY!, + messages: [ + { + role: "system", + content: "from now on, foo is whale", + }, + { + role: "user", + content: "what exactly is foo?", + }, + ], + stream: true, + temperature: 0.5, +}); + +await checkStream(response, ["whale"]); +``` + ## Docs See [the documentation](https://docs.upstash.com/qstash) for details. From 045a8a426d06ed97b15ccb06d2f7c962ee3658de Mon Sep 17 00:00:00 2001 From: ogzhanolguncu Date: Tue, 25 Jun 2024 11:44:47 +0300 Subject: [PATCH 2/2] fix: typo --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 48db196b..86b9d488 100644 --- a/README.md +++ b/README.md @@ -151,8 +151,6 @@ const response = await client.chat().create({ stream: true, temperature: 0.5, }); - -await checkStream(response, ["whale"]); ``` ## Docs