Comments (3)
Hey Eric!
Interesting use case. Right now I think the best approach in our framework is more or less what you've done, i.e. create a custom ChatLlm
interface in your config instead of using our makeOpenAiChatLlm()
constructor. We can consider ways to extend our implementation so that you don't have to write a totally custom implementation.
We haven't worked with LangSmith so I'm not super certain of how LangChain interacts with it. If there's a good integration there, you might also consider using the makeLangchainChatLlm()
constructor with a LangChain OpenAI ChatModel instance. Do you think that would be useful in this case?
from chatbot.
@eric-gardyn if you can would you mind sharing the changes you made to answerQuestionAwaited()
to interact with LangSmith? I'd like to get a feel for what this type of integration looks like so that we could make it easier in future.
from chatbot.
sure, it's quick-and-dirty, but straight-forward, just so I could get it up and running
import { RunTree } from 'langsmith'
(...)
async answerQuestionAwaited(
{ messages, toolCallOptions }: LlmAnswerQuestionParams,
question: string
) {
const pipeline = new RunTree({
name: 'Chat Pipeline',
run_type: 'chain',
inputs: { question },
})
// Create a child run
const childRun = await pipeline.createChild({
name: 'OpenAI Call',
run_type: 'llm',
inputs: { messages },
})
const chatCompletion = await openAiClient.getChatCompletions(deployment, messages, {
...openAiLmmConfigOptions,
...(toolCallOptions ? { functionCall: toolCallOptions } : {}),
functions: tools?.map(tool => {
return tool.definition
}),
})
const {
choices: [choice],
} = chatCompletion
const { message } = choice
if (!message) {
throw new Error('No message returned from OpenAI')
}
// End the runs and log them
childRun.end(chatCompletion)
await childRun.postRun()
pipeline.end({ outputs: { answer: message.content } })
await pipeline.postRun()
return message as ChatRequestAssistantMessage
},
and I changed awaitGenerateResponse to call 'answerQuestionAwaited' with added parameter 'request?.body?.message'
and
export interface ChatLlm {
answerQuestionStream(params: LlmAnswerQuestionParams): Promise<OpenAiStreamingResponse>
answerQuestionAwaited(
params: LlmAnswerQuestionParams,
question?: string
): Promise<OpenAiAwaitedResponse>
callTool?(params: LlmCallToolParams): Promise<CallToolResponse>
}
there might be an easier/better way
from chatbot.
Related Issues (13)
- `ApiConversations` service
- `POST /api-conversation` endpoint to create api conversation for api chat session
- `POST /api-conversations/:conversationId/messages/:messageId/rating` for Api conversation rate message endpoint
- How do you install this? HOT 1
- InputBarTrigger does not accept placeholder HOT 2
- IP error when deploying mongodb-chatbot-server HOT 1
- how to pass parameters from <Chatbot>? HOT 8
- is VECTOR_SEARCH_INDEX_NAME customizable? HOT 3
- Cannot find the LG packages HOT 5
- OPENAI_EMBEDDING_MODEL="text-embedding-3-small" not working? HOT 9
- Info retrieval and LLM function calling with parameter HOT 5
- Documentation improvement: Booster HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatbot.