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 ChatGPT wrapper pipeline #195

Closed
wants to merge 16 commits into from

Conversation

wasnertobias
Copy link
Contributor

@wasnertobias wasnertobias commented Jan 21, 2025

Only to be added temporarily as an experiment.

Summary by CodeRabbit

  • Documentation

    • Updated README.MD with improved structure and naming conventions for configuration files
    • Standardized file naming from llm-config to llm_config
  • New Features

    • Added ChatGPT wrapper pipeline for enhanced chat interactions
    • Introduced new error logging with Sentry SDK integration
  • Improvements

    • Modified OpenAPI schema to include bearer authentication
    • Updated type declarations to support optional fields
    • Refined code formatting in various pipeline components

Copy link
Contributor

coderabbitai bot commented Jan 21, 2025

Walkthrough

This pull request encompasses several modifications across different components of the application. The changes include updating the README documentation with standardized configuration file naming, modifying type declarations in data transfer objects, enhancing OpenAPI schema security, introducing a new ChatGPT wrapper pipeline, and improving error logging with Sentry integration. The modifications aim to improve code structure, documentation clarity, and error tracking capabilities.

Changes

File Change Summary
README.MD Reorganized "Setup" section, standardized configuration file names from llm-config to llm_config
app/domain/status/text_exercise_chat_status_update_dto.py Changed result attribute from str to Optional[str]
app/main.py Added custom_openapi() function to customize OpenAPI schema with bearer authentication
app/pipeline/chat/course_chat_pipeline.py Minor formatting changes in model initialization
app/pipeline/chat/exercise_chat_agent_pipeline.py Slight modification in expression formatting for guide_response
app/pipeline/chat_gpt_wrapper_pipeline.py New pipeline for ChatGPT wrapper interactions
app/pipeline/prompts/chat_gpt_wrapper_prompts.py Added initial system prompt for ChatGPT
app/pipeline/shared/citation_pipeline.py Minor formatting change in string construction
app/web/routers/pipelines.py Added support for ChatGPT wrapper pipeline
app/web/status/status_update.py Integrated Sentry SDK for enhanced error logging

Sequence Diagram

sequenceDiagram
    participant Client
    participant FastAPI
    participant ChatGPTWrapperPipeline
    participant LLM
    
    Client->>FastAPI: Send chat request
    FastAPI->>ChatGPTWrapperPipeline: Initialize pipeline
    ChatGPTWrapperPipeline->>LLM: Generate response
    LLM-->>ChatGPTWrapperPipeline: Return response
    ChatGPTWrapperPipeline-->>FastAPI: Process complete
    FastAPI-->>Client: Return response
Loading

Possibly related PRs

Suggested labels

component:LLM

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@wasnertobias
Copy link
Contributor Author

Followup to #185 and #194 as I was not able to make push any more changes to the existing branch due to rule:
https://github.com/ls1intum/Pyris/rules/3351539?ref=refs%2Fheads%2Ffeature%2Fadd-chatgpt-wrapper-pipeline

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: 1

🧹 Nitpick comments (3)
app/pipeline/chat_gpt_wrapper_pipeline.py (1)

63-63: Remove unused attribute self.tokens

The attribute self.tokens is initialized but not used elsewhere in the class. Removing it can clean up the code.

Apply this diff to remove the unused attribute:

-            self.tokens = []
app/web/routers/pipelines.py (2)

78-83: Consider using pattern matching for variant handling.

The if-else structure for variant handling deviates from the pattern used in other pipeline implementations (e.g., text_exercise_chat_pipeline_worker) which use pattern matching. Consider using a match statement for consistency.

-    if variant == "chat-gpt-wrapper":
-        thread = Thread(target=run_chatgpt_wrapper_pipeline_worker, args=(dto, variant))
-    else:
-        thread = Thread(
-            target=run_exercise_chat_pipeline_worker, args=(dto, variant, event)
-        )
+    match variant:
+        case "chat-gpt-wrapper":
+            thread = Thread(target=run_chatgpt_wrapper_pipeline_worker, args=(dto, variant))
+        case _:
+            thread = Thread(
+                target=run_exercise_chat_pipeline_worker, args=(dto, variant, event)
+            )

325-332: Consider adding more descriptive feature information.

The feature DTO for CHAT_GPT_WRAPPER provides minimal information. Consider enhancing the description to indicate its experimental nature and any limitations or specific use cases.

         case "CHAT_GPT_WRAPPER":
             return [
                 FeatureDTO(
                     id="default",
                     name="Default Variant",
-                    description="Default ChatGPT wrapper variant.",
+                    description="Experimental ChatGPT wrapper variant for direct model interaction. Note: This is a temporary implementation for testing purposes.",
                 )
             ]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ddd77de and 1a3cb04.

⛔ Files ignored due to path filters (2)
  • application.example.yml is excluded by !**/*.yml
  • example_application.yml is excluded by !**/*.yml
📒 Files selected for processing (10)
  • README.MD (6 hunks)
  • app/domain/status/text_exercise_chat_status_update_dto.py (1 hunks)
  • app/main.py (1 hunks)
  • app/pipeline/chat/course_chat_pipeline.py (1 hunks)
  • app/pipeline/chat/exercise_chat_agent_pipeline.py (1 hunks)
  • app/pipeline/chat_gpt_wrapper_pipeline.py (1 hunks)
  • app/pipeline/prompts/chat_gpt_wrapper_prompts.py (1 hunks)
  • app/pipeline/shared/citation_pipeline.py (1 hunks)
  • app/web/routers/pipelines.py (4 hunks)
  • app/web/status/status_update.py (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • app/pipeline/prompts/chat_gpt_wrapper_prompts.py
  • app/pipeline/shared/citation_pipeline.py
  • app/pipeline/chat/course_chat_pipeline.py
  • app/pipeline/chat/exercise_chat_agent_pipeline.py
🧰 Additional context used
🪛 LanguageTool
README.MD

[uncategorized] ~323-~323: Loose punctuation mark.
Context: ...lfile. -PYRIS_LLM_CONFIG_YML_FILE: Path to your llm_config.yml` file. -...

(UNLIKELY_OPENING_PUNCTUATION)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Push Docker Image
🔇 Additional comments (6)
app/pipeline/chat_gpt_wrapper_pipeline.py (1)

88-89: Duplicate calls to self.callback.done() may be unintended

There are two consecutive calls to self.callback.done(). The first call does not pass any arguments, while the second passes final_result=response. Unless both calls serve distinct purposes, consider combining them or removing the redundant call.

app/domain/status/text_exercise_chat_status_update_dto.py (1)

7-7: Change to make result optional is appropriate

Updating result to Optional[str] allows for cases where a result may not be available, enhancing the flexibility of the TextExerciseChatStatusUpdateDTO class.

app/web/routers/pipelines.py (1)

239-261: LGTM! Worker implementation follows established patterns.

The implementation of run_chatgpt_wrapper_pipeline_worker follows the same error handling and logging patterns as other pipeline workers, which is good for consistency and maintainability.

app/web/status/status_update.py (1)

3-3: LGTM! Enhanced error tracking with Sentry integration.

The addition of Sentry SDK for error tracking is a good improvement for monitoring and debugging in production.

README.MD (2)

187-187: LGTM! Clear warning about model requirements.

The warning about requiring models with gpt_version_equivalent of 4.5 or higher is crucial information for users setting up the system.


8-25: LGTM! Improved documentation structure.

The enhanced table of contents with detailed subsections improves navigation and readability of the documentation.

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

Successfully merging this pull request may close these issues.

2 participants