| # import os | |
| # import openai | |
| # openai.api_key = os.environ.get("OPENAI_API_KEY") | |
| # response = openai.Completion.create( | |
| # model="text-davinci-003", | |
| # prompt="\"\"\"\nUtil exposes the following:\n\nutil.stripe() -> authenticates & returns the stripe module; usable as stripe.Charge.create etc\n\"\"\"\nimport util\n\"\"\"\nCreate a Stripe token using the users credit card: 5555-4444-3333-2222, expiration date 12 / 28, cvc 521\n\"\"\"", | |
| # temperature=0, | |
| # max_tokens=100, | |
| # top_p=1.0, | |
| # frequency_penalty=0.0, | |
| # presence_penalty=0.0, | |
| # stop=["\"\"\""] | |
| # ) | |
| import os | |
| import json | |
| import requests | |
| from text_generation import InferenceAPIClient | |
| hf_api_key = os.environ.get("API_TOKEN") | |
| if hf_api_key is None: | |
| raise ValueError("HF_API_KEY environment variable not set, cannot use HF API to generate text.") | |
| client = InferenceAPIClient("facebook/opt-125m", token=hf_api_key, timeout=60) | |
| api_outputs = generate_with_api(prompt, args) | |
| yield from api_outputs | |