Anthropic AI models support
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# How to Alwrity - Getting Started
|
||||
|
||||
Alwrity assists content creators and digital marketers in keyword web research, AI website & Social media content generation & AI Copywriting.
|
||||
Our toolkit integrates (OpenAI, Gemini) AI models for text generation, image creation(Stability.ai), STT(whisper, AssemblyAI) and Web or local data analysis, streamlining your content creation pipeline and ensuring high-quality output with minimal effort.
|
||||
Our toolkit integrates (OpenAI, Gemini, Anthropic) AI models for text generation, image creation(Stability.ai), STT(whisper, AssemblyAI) and Web or local data analysis, streamlining your content creation pipeline and ensuring high-quality output with minimal effort.
|
||||
|
||||
Prompting is abstracted to get going sooner. Focus on your content quality, rather than AI tooling around it.
|
||||
Alwrity gives personalization, factual web researched & SEO optimized content and tools for automating content & digital marketing.
|
||||
@@ -58,8 +58,11 @@ If you have 💻 Laptop + 🛜 Internet + 10 minutes, you will be generating blo
|
||||
| 14 | Agentic Content Creation | Explores innovative content creation methods with CrewAI. |
|
||||
| 15 | AI Finance Writer | Uses ufinance & padnas_ta to write TA report for given stock symbol |
|
||||
| 16 | AI Agents Team | Easily create AI Agents team for Content creation & Digital marketing |
|
||||
| 17 | Talk to your Docs | Write content from your local documents of any type(multi-modal) |
|
||||
| 17 | Talk to your Docs (WIP) | Write content from your local documents of any type(multi-modal) |
|
||||
| 18 | Wordpress API integration | Programmatically upload blogs to wordpress website with API keys |
|
||||
| 19 | Talk to your website | Crawl Crawl your entire website & write content based on its content, Or Not |
|
||||
| 20 | Content From URLs | Provide any URL to create an original, unique content from |
|
||||
|
||||
---
|
||||
|
||||
# AI Content Generation Toolkit - Alwrity
|
||||
|
||||
33
lib/gpt_providers/text_generation/anthropic_text_gen.py
Normal file
33
lib/gpt_providers/text_generation/anthropic_text_gen.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
|
||||
import anthropic
|
||||
from anthropic import Anthropic
|
||||
import streamlit as st
|
||||
|
||||
|
||||
def anthropic_text_response(prompt):
|
||||
""" """
|
||||
client = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"),)
|
||||
|
||||
try:
|
||||
response = client.messages.create(
|
||||
max_tokens=1024,
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": prompt,
|
||||
}
|
||||
],
|
||||
# This will come from config file.
|
||||
model="claude-3-opus-20240229",
|
||||
)
|
||||
return(message.content)
|
||||
except anthropic.APIConnectionError as e:
|
||||
st.error("The server could not be reached")
|
||||
st.error(e.__cause__) # an underlying Exception, likely raised within httpx.
|
||||
except anthropic.RateLimitError as e:
|
||||
st.error("A 429 status code was received; we should back off a bit.")
|
||||
except anthropic.APIStatusError as e:
|
||||
st.error("Another non-200-range status code was received")
|
||||
st.error(e.status_code)
|
||||
st.error(e.response)
|
||||
@@ -14,6 +14,7 @@ logger.add(sys.stdout,
|
||||
|
||||
from .openai_text_gen import openai_chatgpt
|
||||
from .gemini_pro_text import gemini_text_response
|
||||
from .anthropic_text_gen import anthropic_text_response
|
||||
from ...utils.read_main_config_params import read_return_config_section
|
||||
|
||||
|
||||
@@ -49,6 +50,14 @@ def llm_text_gen(prompt):
|
||||
except Exception as err:
|
||||
logger.error(f"Failed to get response from Openai: {err}")
|
||||
raise err
|
||||
elif 'anthropic' in gpt_provider.lower():
|
||||
try:
|
||||
logger.info(f"Using Anthropic Model: {model} for text Generation.")
|
||||
response = anthropic_text_response(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
logger.error(f"Failed to get response from Anthropic: {err}")
|
||||
raise err
|
||||
|
||||
except Exception as err:
|
||||
logger.error(f"Failed to read LLM parameters: {err}")
|
||||
@@ -95,6 +104,8 @@ def get_api_key(gpt_provider):
|
||||
api_key = os.getenv('GEMINI_API_KEY')
|
||||
elif gpt_provider.lower() == 'openai':
|
||||
api_key = os.getenv('OPENAI_API_KEY')
|
||||
elif gpt_provider.lower() == 'anthropic':
|
||||
api_key = os.getenv('ANTHROPIC_API_KEY')
|
||||
|
||||
if not api_key:
|
||||
raise ValueError(f"No API key found for the specified GPT provider: '{gpt_provider}'")
|
||||
|
||||
@@ -9,7 +9,7 @@ crewai_tools
|
||||
python-docx
|
||||
PyPDF2
|
||||
google.generativeai
|
||||
mistralai
|
||||
anthropic
|
||||
tenacity
|
||||
tavily-python
|
||||
tabulate
|
||||
@@ -35,3 +35,4 @@ pandas_ta
|
||||
firecrawl-py
|
||||
gTTS
|
||||
streamlit-mic-recorder
|
||||
|
||||
|
||||
Reference in New Issue
Block a user