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

Does this work on Windows? #2

Open
w013nad opened this issue Jan 7, 2025 · 2 comments
Open

Does this work on Windows? #2

w013nad opened this issue Jan 7, 2025 · 2 comments

Comments

@w013nad
Copy link

w013nad commented Jan 7, 2025

I tried running this on windows but it immediately fails and then messes up my terminal. I can't post images atm but it looks like this whenever I scroll, click, or use any special keys. I suspect it's something with the app. I'm looking into calling the function directly but I'm not sure how to do it.

[555555;75;27M[555555;75;28M[555555;75;28M[444444;75;28M[444444;75;28M[444444;75;28M[444444;76;28M[444444;76;27M[555555;94;26M[555555;94;26M[555555;94;27M[555555;93;27M[555555;93;27M[555555;92;28M[555555;92;28M[555555;92;29M[555555;92;29M[444444;92;29M[444444;92;29M[444444;92;29M[444444;92;29M[444444;92;29M[444444;92;29M[444444;92;29M[444444;92;29M[555555;90;29M[555555;90;29M[555555;90;29M[92;29M[92;29M[92;29M[;;92;29M[;;92;29M[;;92;29M[222;93;29M[93;29M[;;93;29M[;;93;29M[93;29m```
@w013nad
Copy link
Author

w013nad commented Jan 7, 2025

For anyone interested. Here's what I did.

import asyncio
from promptimal.optimizer import optimize
instruction="insert your instruction here"
async def main():
    last_step = None
    async for step in optimize(
        prompt=instruction,
        improvement_request="I'm trying to get an LLM to convert sentences more accurately.",
        population_size=5,
        num_iters=5,
        num_elites=2,
        threshold=1.0,
        api_key="EMPTY",
    ):
        last_step = step
        if hasattr(step, 'is_terminal') and step.is_terminal:
            print("Final Result:")
        else:
            print("Intermediate Step:")
        print(f"Index: {step.index}, Value: {step.value}, Message: {step.message}")
        print(f"Best Prompt: {step.best_prompt}, Best Score: {getattr(step, 'best_score', None)}")
        print(f"Token Count: {step.token_count}, Num Prompts: {getattr(step, 'num_prompts', None)}")
        print(f"Start Time: {step.start_time}, End Time: {getattr(step, 'end_time', None)}")
        print("-" * 50)

    # Print the final result again for clarity
    if last_step:
        print("\nFinal Optimized Prompt:")
        print(f"Prompt: {last_step.best_prompt}")
        print(f"Score: {getattr(last_step, 'best_score', None)}")

asyncio.run(main())

@Darkmoth
Copy link

My friend, you are a lifesaver. This code worked like a charm!

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

No branches or pull requests

2 participants