diff --git a/README.md b/README.md index 5c92af7..d03440d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@

Promptify

-

Task-based NLP engine with Pydantic structured outputs, built-in evaluation, and LiteLLM as the universal LLM backend. Think "scikit-learn for LLM-powered NLP". @@ -173,6 +171,64 @@ scores = evaluate(task=ner, dataset=labeled_data, metrics=["precision", "recall" | Topic Modelling | `ExtractTopics` | list of topics | | Custom Task | `Task` | any Pydantic `BaseModel` | +## FAQ + +### How do I set up API keys for different providers? + +Promptify uses LiteLLM as the backend, so API keys are set via environment variables: + +```bash +# OpenAI +export OPENAI_API_KEY="your-key" + +# Anthropic +export ANTHROPIC_API_KEY="your-key" + +# Google +export GOOGLE_API_KEY="your-key" + +# For local models (Ollama), no API key needed +# Just ensure Ollama is running locally +``` + +### How do I add few-shot examples to improve accuracy? + +Pass examples to any task: + +```python +ner = NER( + model="gpt-4o-mini", + examples=[ + ("Patient has diabetes", [Entity(text="diabetes", label="CONDITION")]), + ("John is 45 years old", [Entity(text="45", label="AGE")]), + ] +) +``` + +### What if my provider doesn't support structured outputs? + +Promptify includes a safe fallback parser that extracts JSON from text responses without using `eval()`. This works automatically for providers without native structured output support. + +### How do I track API costs? + +Use `get_cost_summary()` on any task instance: + +```python +ner = NER(model="gpt-4o-mini") +result = ner("some text") +print(ner.get_cost_summary()) +``` + +### Can I use Promptify with Azure OpenAI? + +Yes! Use the `azure/` prefix: + +```python +ner = NER(model="azure/gpt-4") +``` + +Make sure to set `AZURE_API_KEY`, `AZURE_API_BASE`, and `AZURE_API_VERSION` environment variables. + ## Community

If you are interested in Prompt-Engineering, LLMs, and NLP, please consider joining PromptsLab
@@ -180,8 +236,6 @@ If you are interested in Prompt-Engineering, LLMs, and NLP, please consider join Join us on Discord - - ``` @misc{Promptify2022,