Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce chatModels #43

Closed
ChristianSch opened this issue Apr 21, 2023 · 6 comments
Closed

Introduce chatModels #43

ChristianSch opened this issue Apr 21, 2023 · 6 comments

Comments

@ChristianSch
Copy link

I already started with openai but have the need to discuss how we want to map langchain to langchaingo in a few instances. I'll make a PR soon.

@ChristianSch
Copy link
Author

I would like to highlight my biggest problem. We have the ChatMessage as follows:

type ChatMessage interface {
	GetText() string
	GetType() ChatMessageType // <- role
}

The openAI API needs separated role and message fields though: https://platform.openai.com/docs/api-reference/chat/create. They are required.

The LLM contract allows passing strings only though.

// LLM is a langchaingo Large Language Model.
type LLM interface {
	Call(prompt string, stopWords []string) (string, error)
	Generate(prompts []string, stopWords []string) ([]*Generation, error)
}

The reference implementation seems to handle it by not using string-only messages:

chat([HumanMessage(content="Translate this sentence from English to French. I love programming.")])

Maybe we could generalize the LLM input to be a BaseMessage as well, and then strongly type it for all implementations? (Normal LLMs just get a text as input, chat role and text etc.)

What are everyone's thoughts? (@tmc?)

@tmc
Copy link
Owner

tmc commented Apr 21, 2023

Hmm. I think we need to think through if “type” is sufficiently distinct from “role”. We have the role field on the GenericChatMessage struct.

@ChristianSch
Copy link
Author

What's the type based upon?

@tmc
Copy link
Owner

tmc commented Apr 26, 2023

What's the type based upon?

That's just a copy of the concept from https://github.com/hwchase17/langchain/blob/master/langchain/schema.py#L88

See "role" here: https://github.com/hwchase17/langchain/blob/master/langchain/schema.py#L106 (and used here: https://github.com/hwchase17/langchain/blob/master/langchain/schema.py#L33)

@ChristianSch sorry I missed your follow-up comment here. Please feel free to join us in the langchain chat in the #langchain-go channel.

@ChristianSch
Copy link
Author

Ahhh ok. So we'd need to have a look. It's not very self-explanatory haha.

No worries. Which platform @tmc? Discord, Gitter, Matrix?

@tmc
Copy link
Owner

tmc commented Apr 26, 2023

Ahhh ok. So we'd need to have a look. It's not very self-explanatory haha.

No worries. Which platform @tmc? Discord, Gitter, Matrix?

Sorry I should have indicated, we're in the langchain discord. (we should put this in the README..).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants