Closed lebsral closed 1 month ago
I will fix that. It's because people working with it create the modules in the cloned project, then move over to their project when tested. I can change it to be local
Thanks! Any fix that prevents me from screwing things up is always welcome.
All you have to do is copy and paste that file to your own project. It won't hurt anything. That is why I just print it to the CLI.
Fixed
this is all directly copy pasted from my zsh terminal. dspygen version 2024.6.19. installed in a fresh environment in a new dspygen generated project.
(dspygen) lars@MacBook-Pro-10 mydspygenproject % dspygen module new -cn CodeGenerator -i "prompt" -o "generated_code"
"""
""" import dspy from dspygen.utils.dspy_tools import init_dspy
class CodeGeneratorModule(dspy.Module): """CodeGeneratorModule"""
from typer import Typer app = Typer()
@app.command() def call(prompt): """CodeGeneratorModule""" init_dspy()
def code_generator_call(prompt): code_generator = CodeGeneratorModule() return code_generator.forward(prompt=prompt)
def main(): init_dspy() prompt = "" result = code_generator_call(prompt=prompt) print(result)
from fastapi import APIRouter router = APIRouter()
@router.post("/code_generator/") async def code_generator_route(data: dict):
Your code generation logic here
""" import streamlit as st
Streamlit form and display
st.title("CodeGeneratorModule Generator") prompt = st.text_input("Enter prompt")
if st.button("Submit CodeGeneratorModule"): init_dspy()
"""
if name == "main": main()
Module saved to /Users/lars/anaconda3/envs/dspygen/lib/python3.11/site-packages/dspygen/modules/code_generator_module.py (dspygen) lars@MacBook-Pro-10 mydspygenproject %