You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement model wrapper for AI content generation (#58)
### Issue
<!-- Please link the GitHub issues related to this PR, if available -->
### Description
This PR introduces the new ModelWrapper feature, which encapsulates
model logic using the pydantic-ai Agent. The ModelWrapper enables
flexible integration with multiple LLM providers and centralizes
AI-powered content generation. Key changes include:
- Addition of the `ModelWrapper` class in
`struct_module/model_wrapper.py`
- Integration of ModelWrapper into `FileItem` and related modules
- Improved test and workflow configuration to support AI model usage
- Ensured environment variable handling for API keys in CI and local
development
These changes improve modularity, testability, and future extensibility
for AI-powered features.
### Checklist
- [x] I have read the [contributing
guidelines](https://github.com/httpdss/struct/blob/main/README.md#contributing).
- [x] My code follows the code style of this project.
- [x] I have performed a self-review of my own code.
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] New and existing unit tests pass locally with my changes.
- [x] I have updated the documentation accordingly.
### Screenshots (if applicable)
<!-- Add screenshots to illustrate the changes made in the pull request
-->
### Additional Comments
- The main feature is the ModelWrapper, which standardizes model usage
across the codebase.
- The test workflow now sets a dummy `OPENAI_API_KEY` for CI
compatibility.
self.logger.warning("Skipping processing prompt as OpenAI API key is not set.")
64
-
return
65
48
66
49
ifnotself.system_prompt:
67
50
system_prompt="You are a software developer working on a project. You need to create a file with the following content:"
68
51
else:
69
52
system_prompt=self.system_prompt
70
53
71
-
# If existing_content is provided, append it to the user prompt
72
54
user_prompt=self.user_prompt
73
55
ifexisting_content:
74
56
user_prompt+=f"\n\nCurrent file content (if any):\n```\n{existing_content}\n```\n\nPlease modify existing content so that it meets the new requirements. Your output should be plain text, without any code blocks or formatting. Do not include any explanations or comments. Just provide the final content of the file."
75
57
76
58
self.logger.debug(f"Using system prompt: {system_prompt}")
77
59
self.logger.debug(f"Using user prompt: {user_prompt}")
78
60
79
-
ifdry_run:
80
-
self.logger.info("[DRY RUN] Would generate content using OpenAI API.")
81
-
self.content="[DRY RUN] Generating content using OpenAI"
0 commit comments