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

Add LabelStudio integration #8880

Merged
merged 20 commits into from Aug 11, 2023
Merged

Add LabelStudio integration #8880

merged 20 commits into from Aug 11, 2023

Conversation

niklub
Copy link
Contributor

@niklub niklub commented Aug 7, 2023

This PR introduces Label Studio integration with LangChain via LabelStudioCallbackHandler:

  • sending data to the Label Studio instance
  • labeling dataset for supervised LLM finetuning
  • rating model responses
  • tracking and displaying chat history
  • support for custom data labeling workflow

Example

chat_llm = ChatOpenAI(callbacks=[LabelStudioCallbackHandler(mode="chat")])
chat_llm([
    SystemMessage(content="Always use emojis in your responses."),
        HumanMessage(content="Hey AI, how's your day going?"),
    AIMessage(content="🤖 I don't have feelings, but I'm running smoothly! How can I help you today?"),
        HumanMessage(content="I'm feeling a bit down. Any advice?"),
    AIMessage(content="🤗 I'm sorry to hear that. Remember, it's okay to seek help or talk to someone if you need to. 💬"),
        HumanMessage(content="Can you tell me a joke to lighten the mood?"),
    AIMessage(content="Of course! 🎭 Why did the scarecrow win an award? Because he was outstanding in his field! 🌾"),
        HumanMessage(content="Haha, that was a good one! Thanks for cheering me up."),
    AIMessage(content="Always here to help! 😊 If you need anything else, just let me know."),
        HumanMessage(content="Will do! By the way, can you recommend a good movie?"),
])
image

Dependencies

https://twitter.com/labelstudiohq

@vercel
Copy link

vercel bot commented Aug 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 10, 2023 10:04pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain-deprecated ⬜️ Ignored (Inspect) Visit Preview Aug 10, 2023 10:04pm

@dosubot dosubot bot added the 🤖:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features label Aug 7, 2023
@baskaryan
Copy link
Collaborator

@niklub very exciting, feel free to ping when it's ready for review!

Copy link

@hogepodge hogepodge left a comment

Choose a reason for hiding this comment

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

Ran through this tutorial locally, and ran into the following issues. The last is fatal for me.

docs/extras/integrations/callbacks/labelstudio.ipynb Outdated Show resolved Hide resolved
docs/extras/integrations/callbacks/labelstudio.ipynb Outdated Show resolved Hide resolved
docs/extras/integrations/callbacks/labelstudio.ipynb Outdated Show resolved Hide resolved
@hogepodge
Copy link

Tested and verified locally on my Label Studio setup. LGTM!

Copy link

@hogepodge hogepodge left a comment

Choose a reason for hiding this comment

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

Everything looks good in my testing.

@niklub niklub marked this pull request as ready for review August 11, 2023 09:39
@niklub
Copy link
Contributor Author

niklub commented Aug 11, 2023

@baskaryan @agola11 we're ready for your review!

@baskaryan
Copy link
Collaborator

looks good to me, thanks @niklub and @hogepodge!

@baskaryan baskaryan merged commit 16af5f8 into langchain-ai:master Aug 11, 2023
22 checks passed
danielchalef pushed a commit to danielchalef/langchain that referenced this pull request Aug 11, 2023
This PR introduces [Label Studio](https://labelstud.io/) integration
with LangChain via `LabelStudioCallbackHandler`:

- sending data to the Label Studio instance
- labeling dataset for supervised LLM finetuning
- rating model responses
- tracking and displaying chat history
- support for custom data labeling workflow

### Example

```
chat_llm = ChatOpenAI(callbacks=[LabelStudioCallbackHandler(mode="chat")])
chat_llm([
    SystemMessage(content="Always use emojis in your responses."),
        HumanMessage(content="Hey AI, how's your day going?"),
    AIMessage(content="🤖 I don't have feelings, but I'm running smoothly! How can I help you today?"),
        HumanMessage(content="I'm feeling a bit down. Any advice?"),
    AIMessage(content="🤗 I'm sorry to hear that. Remember, it's okay to seek help or talk to someone if you need to. 💬"),
        HumanMessage(content="Can you tell me a joke to lighten the mood?"),
    AIMessage(content="Of course! 🎭 Why did the scarecrow win an award? Because he was outstanding in his field! 🌾"),
        HumanMessage(content="Haha, that was a good one! Thanks for cheering me up."),
    AIMessage(content="Always here to help! 😊 If you need anything else, just let me know."),
        HumanMessage(content="Will do! By the way, can you recommend a good movie?"),
])
```

<img width="906" alt="image"
src="https://github.com/langchain-ai/langchain/assets/6087484/0a1cf559-0bd3-4250-ad96-6e71dbb1d2f3">


### Dependencies
- [label-studio](https://pypi.org/project/label-studio/)
- [label-studio-sdk](https://pypi.org/project/label-studio-sdk/)

https://twitter.com/labelstudiohq

---------

Co-authored-by: nik <nik@heartex.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants