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

feat: Added Deep Infra Provider #261

Merged
merged 2 commits into from
Apr 27, 2024
Merged

feat: Added Deep Infra Provider #261

merged 2 commits into from
Apr 27, 2024

Conversation

gunpal5
Copy link
Contributor

@gunpal5 gunpal5 commented Apr 27, 2024

Added Deep Infra Provider with Source Generator

Summary by CodeRabbit

  • New Features
    • Introduced new projects and configurations for expanding provider capabilities and code generation tools.
    • Added new classes for configuring and managing DeepInfra models and providers.
    • Implemented tests and tools for generating and managing predefined models.
  • Enhancements
    • Enhanced OpenAiProvider with additional API version parameter to support different API versions.
  • Refactor
    • Reorganized project structures and updated project paths to streamline development and build processes.

Copy link
Contributor

coderabbitai bot commented Apr 27, 2024

Walkthrough

The recent updates to the LangChain solution involve significant enhancements to the DeepInfra provider, including new projects for code generation and integration tests, as well as the introduction of new classes for model management and configuration. Additionally, changes to the OpenAI provider reflect an update in the API version handling.

Changes

Files Changes
LangChain.sln, .../DeepInfra.csproj, .../DeepInfra.Tests.csproj, .../OpenAI.csproj Updated project configurations, paths, and references. Added new projects.
.../DeepInfra/*.cs, .../OpenAI/OpenAiProvider.cs Introduced new classes for configuration, model management, and API version handling.
.../DeepInfra/tests/*.cs Added new test cases and functionalities for the DeepInfra provider.
.../DeepInfra/tools/.../CodeGenerator/*.cs, .../Program.cs Developed code generation tools for managing DeepInfra model information and enums.

🐇✨
Code hops through fields of change,
New models grow, oh how strange!
With each commit, a new leap,
In LangChain's code, secrets we keep.
Celebrate, for progress beams,
In the lands of code and dreams.
🌟📜


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 687c0e2 and 03d89ca.
Files selected for processing (1)
  • src/Providers/DeepInfra/tools/LangChain.Providers.DeepInfra.CodeGenerator/Main/DeepInfraCodeGenerator.cs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/Providers/DeepInfra/tools/LangChain.Providers.DeepInfra.CodeGenerator/Main/DeepInfraCodeGenerator.cs

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

sweep-ai bot commented Apr 27, 2024

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Refactor large functions to be more modular.
  • Apply: Add docstrings to all functions and file headers.

This is an automated message generated by Sweep AI.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Out of diff range and nitpick comments (4)
src/Providers/DeepInfra/src/DeepInfraConfiguration.cs (1)

5-7: Fill the summary tags to provide better documentation for the DeepInfraConfiguration class.

src/Providers/DeepInfra/src/DeepInfraProvider.cs (1)

6-15: Ensure to add documentation for the constructors to explain the parameters and their usage, especially the custom endpoint and API version.

src/Providers/DeepInfra/src/DeepInfraModel.cs (1)

6-23: Ensure to add documentation for the constructors to explain the parameters and their usage, especially the model retrieval and default pricing values.

src/Providers/DeepInfra/src/DeepInfraModelIds.cs (1)

26-26: Complete the description for the model Meta-Llama-3-8B-Instruct.

Consider adding a detailed description for this model to maintain consistency with other entries.

Comment on lines +363 to +366
using var handler = new HttpClientHandler();
//handler.CheckCertificateRevocationList = true;
handler.AutomaticDecompression =
DecompressionMethods.Deflate | DecompressionMethods.Brotli | DecompressionMethods.GZip;
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider enabling certificate revocation check for enhanced security.

+ handler.CheckCertificateRevocationList = true;

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
using var handler = new HttpClientHandler();
//handler.CheckCertificateRevocationList = true;
handler.AutomaticDecompression =
DecompressionMethods.Deflate | DecompressionMethods.Brotli | DecompressionMethods.GZip;
using var handler = new HttpClientHandler();
handler.CheckCertificateRevocationList = true;
handler.AutomaticDecompression =
DecompressionMethods.Deflate | DecompressionMethods.Brotli | DecompressionMethods.GZip;

Comment on lines +9 to +30
[Test]
public async Task GetWeather()
{
var apiKey =
Environment.GetEnvironmentVariable("Deep_Infra_Key") ??
throw new InvalidOperationException("Deep_Infra_Key environment variable is not found.");

var model = new Mixtral8X7BInstructV01Model(new DeepInfraProvider(apiKey));

var service = new WeatherService();
model.AddGlobalTools(service.AsTools(), service.AsCalls());

var response = await model.GenerateAsync(
new[]
{
"You are a helpful weather assistant.".AsSystemMessage(),
"What's the weather like today?".AsHumanMessage(),
"Sure! Could you please provide me with your location?".AsAiMessage(),
"Dubai, UAE".AsHumanMessage(),
});

Console.WriteLine(response.Messages.AsHistory());
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding assertions to validate the expected behavior of the GetWeather test.

This test currently does not assert any conditions, which means it will not effectively validate the correctness of the GetWeather functionality. Consider using assertions to check the contents of response.Messages or other relevant properties to ensure the test is meaningful.

@@ -0,0 +1,8 @@
{
"profiles": {
"LangChain.Providers.OpenRouter.CodeGenerator": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct the project name in the launch settings to match the Deep Infra code generator.

…deGenerator/Main/DeepInfraCodeGenerator.cs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@HavenDV HavenDV enabled auto-merge (squash) April 27, 2024 22:12
@HavenDV HavenDV merged commit 203c046 into tryAGI:main Apr 27, 2024
2 of 3 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants