Skip to content

Commit

Permalink
add correct stop condition + remove dist folder in actions before bui…
Browse files Browse the repository at this point in the history
…ld, just in case
  • Loading branch information
eg9y committed May 27, 2023
1 parent 4645b22 commit e6367ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy
on:
push:
branches:
- main # Or your default branch
- main
jobs:
deploy:
runs-on: ubuntu-latest
Expand All @@ -18,5 +18,6 @@ jobs:
cd promptsandbox.io
git pull
yarn workspace @chatbutler/shared build
if [ -d "packages/server/dist" ]; then rm -r packages/server/dist; fi
yarn workspace @chatbutler/server build
pm2 restart ecosystem.config.js
36 changes: 21 additions & 15 deletions packages/shared/src/runNode/search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConversationalRetrievalQAChain } from "langchain/chains";
import { ChatOpenAI } from "langchain/chat_models/openai";
import { AzureOpenAIInput, ChatOpenAI, OpenAIChatInput } from "langchain/chat_models/openai";
import { OpenAIEmbeddings } from "langchain/embeddings/openai";
import { Node } from "reactflow";
import { getNodes } from "../getNodes";
Expand All @@ -14,6 +14,7 @@ import { setupSupabaseClient } from "../utils/setupSupabaseClient";
import { SupabaseVectorStoreWithFilter } from "../utils/vectorStores/SupabaseVectorStoreWithFilter";
import { getRuntimeEnvironment } from "../utils/env";
import { SupabaseSettingsType } from "../types/SupabaseSettingsType";
import { BaseChatModelParams } from "langchain/dist/chat_models/base";

const search = async (
state: TraversalStateType,
Expand All @@ -23,6 +24,23 @@ const search = async (
openAiKey: string,
supabaseSettings: SupabaseSettingsType
) => {
const openAiOptions: Partial<OpenAIChatInput> & Partial<AzureOpenAIInput> & BaseChatModelParams & {
concurrency?: number;
cache?: boolean;
openAIApiKey?: string;
}
= {
// TODO: need to let user set the openai settings
modelName: node.data.model,
maxTokens: Math.floor(node.data.max_tokens),
temperature: node.data.temperature,
openAIApiKey: openAiKey,
}

if (node.data.stop.length > 0) {
openAiOptions.stop = node.data.stop;
}

try {
const inputs = node.data.inputs;
const inputIds = inputs.inputs.filter((input) => input !== "docsLoader");
Expand All @@ -41,19 +59,7 @@ const search = async (
throw new Error(session.error.message);
}

const openAiOptions: any = {
// TODO: need to let user set the openai settings
modelName: node.data.model,
maxTokens: Math.floor(node.data.max_tokens),
temperature: node.data.temperature,
openAIApiKey: openAiKey,
}

if (node.data.stop) {
openAiOptions.stop = node.data.stop;
}




let model = new ChatOpenAI(openAiOptions);

Expand All @@ -77,7 +83,7 @@ const search = async (
);
model = new ChatOpenAI(
{
modelName: "gpt-3.5-turbo",
...openAiOptions,
// this is the supabase session key, the real openAI key is set in the proxy #ifitworksitworks
openAIApiKey: session.data.session.access_token,
},
Expand Down

1 comment on commit e6367ed

@vercel
Copy link

@vercel vercel bot commented on e6367ed May 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.