Skip to content

Commit

Permalink
Merge pull request #16 from Broomva/feat/chat_agent
Browse files Browse the repository at this point in the history
Feat/chat agent
  • Loading branch information
broomva authored Mar 4, 2024
2 parents f7deb8b + d13b5b5 commit 67cb2e6
Show file tree
Hide file tree
Showing 21 changed files with 1,904 additions and 1,185 deletions.
88 changes: 65 additions & 23 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,23 +1,65 @@
POSTGRES_USERNAME=''
POSTGRES_PASSWORD=''
POSTGRES_HOST=''
POSTGRES_PORT=''
POSTGRES_DATABASE=''
LANGCHAIN_TRACING_V2=''
LANGCHAIN_ENDPOINT=''
LANGCHAIN_API_KEY=''
LANGCHAIN_PROJECT=''
DAGSTER_HOME=''
OPENAI_API_BASE_URL=''
OPENAI_MODEL_NAME=''
TOGETHER_API_KEY=''
BROWSERLESS_API_KEY=''
SERP_API_KEY=''
SQLALCHEMY_URL=''
OPENAI_API_KEY=''
CHAINLIT_API_KEY=''
OAUTH_GITHUB_CLIENT_ID=''
OAUTH_GITHUB_CLIENT_SECRET=''
CHAINLIT_AUTH_SECRET=''
HUGGINGFACEHUB_API_TOKEN=''
SENDGRID_API_KEY=''
# PostgreSQL Configuration
POSTGRES_USERNAME=your_postgres_username
POSTGRES_PASSWORD=your_postgres_password
POSTGRES_HOST=your_postgres_host
POSTGRES_PORT=5432
POSTGRES_DATABASE=your_postgres_database_name

# SQLAlchemy URL (Example: postgresql://username:password@host:port/database)
SQLALCHEMY_URL=your_sqlalchemy_database_url

# LangChain Configuration
LANGCHAIN_TRACING_V2=true/false
LANGCHAIN_ENDPOINT=your_langchain_endpoint
LANGCHAIN_API_KEY=your_langchain_api_key
LANGCHAIN_PROJECT=your_langchain_project_name

# Dagster Home Directory
DAGSTER_HOME=your_dagster_home_directory_path

# TogetherAI API Configuration
TOGETHERAI_API_BASE_URL=your_togetherai_api_base_url
TOGETHERAI_MODEL_NAME=your_togetherai_model_name
TOGETHERAI_API_KEY=your_togetherai_api_key

# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=your_openai_model_name

# Browserless and SERP API Configuration
BROWSERLESS_API_KEY=your_browserless_api_key
SERP_API_KEY=your_serp_api_key

# ChainLit and OAuth for GitHub Configuration
CHAINLIT_API_KEY=your_chainlit_api_key
OAUTH_GITHUB_CLIENT_ID=your_oauth_github_client_id
OAUTH_GITHUB_CLIENT_SECRET=your_oauth_github_client_secret

# ChainLit Authentication Secret and Hugging Face Hub Token
CHAINLIT_AUTH_SECRET=your_chainlit_auth_secret
HUGGINGFACEHUB_API_TOKEN=your_huggingfacehub_api_token

# SMTP Configuration for Email Sending
SMTP_USER=your_smtp_user
SMTP_PASSWORD=your_smtp_password
SMTP_HOST=your_smtp_host
SMTP_PORT=your_smtp_port
SMTP_SSL=enable_or_disable

# SendGrid API Key
SENDGRID_API_KEY=your_sendgrid_api_key

# Twilio Configuration for SMS and Voice Services
TWILIO_RECOVERY_CODE=your_twilio_recovery_code
TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_NUMBER=your_twilio_number

# Admin User ID
ADMIN_USER_ID=your_admin_user_id

# Tavily API Key
TAVILY_API_KEY=your_tavily_api_key

# Application Port
PORT=your_application_port
2 changes: 1 addition & 1 deletion .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
done
' sh {} +
fi
- name: Auto Lint with black, pylint
- name: Auto Lint with black
run: |
black .
black --diff --check $(git ls-files '*.py')
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ deploy_service:
dagster-webserver -h 0.0.0.0 -p 3001 && dagster-daemon run

deploy_api:
python -m uvicorn vortex.api:app --port 10000 &
python -m uvicorn vortex.api:app --port 8000 && ngrok http 8000

# && ngrok http 10000
78 changes: 78 additions & 0 deletions notebooks/vortex_agent.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/broomva/miniconda3/envs/vortex/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"source": [
"from vortex.ai.agents import VortexSession\n",
"from vortex.datamodels import get_db_context"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Using reloaded agent with history [HumanMessage(content='Yo'), AIMessage(content='Hello! How can I assist you today?'), HumanMessage(content='Hola'), AIMessage(content='¡Hola! ¿En qué puedo ayudarte hoy?'), HumanMessage(content='Hey'), AIMessage(content='Hello! How can I assist you today?'), HumanMessage(content='Chat here'), AIMessage(content='Sure, feel free to chat here. What would you like to talk about or ask?'), HumanMessage(content='Puedes hablar en español?'), AIMessage(content='¡Sí, puedo hablar en español! ¿En qué puedo ayudarte hoy?'), HumanMessage(content='Buenas tardes'), AIMessage(content='¡Buenas tardes! ¿Cómo estás? ¿Hay algo en lo que pueda ayudarte hoy?'), HumanMessage(content='Hola'), AIMessage(content='¡Hola! ¿En qué puedo ayudarte hoy?'), HumanMessage(content='Please search this website and summarize what it states https://www.omegle.com/'), AIMessage(content='The search results for the website \"https://www.omegle.com/\" provide various information about Omegle. Here is a summary of what the search results state:\\n\\n1. Omegle has had a positive impact beyond the site through its moderation efforts. It has worked with law enforcement agencies and the National Center for Missing and Exploited Children to help put wrongdoers in prison.\\n2. Omegle is available as an app that can be downloaded on Android and used on PC (Windows 10/8/7/XP) and iOS devices. It is a free chat room where users can connect with millions of people without the need for login.\\n3. Omegle was a free, web-based online chat service that allowed users to socialize with others without the need to register. The service randomly paired users in one-on-one chat sessions where they could chat anonymously.\\n4. Omegle was involved in a lawsuit, and the founder, Leif K. Brooks, shuttered the platform after settling the lawsuit.\\n5. Omegle\\'s alternative, Omegle TV, offers a platform for random video chat with hundreds of thousands of online users. Users can select a preferred country, define their gender, or choose to chat as a couple.\\n\\nIf you would like more detailed information or specific details about Omegle, feel free to ask!'), HumanMessage(content='Please search and summarize the key points of the elon musk vs openai lawsuit'), AIMessage(content=\"The key points of the Elon Musk vs OpenAI lawsuit are as follows:\\n\\n1. Elon Musk is suing OpenAI and its CEO, Sam Altman, for breach of contract. Musk claims that OpenAI has diverged from its original nonprofit mission by partnering with Microsoft for $13 billion and keeping its code for its newest generative AI products a secret.\\n2. Musk, who co-founded OpenAI in 2015, has formed his own AI company, xAI, which has taken OpenAI from a worthless state to a valuation of $90 billion in just a few years. Sam Altman is credited as the key to the company's success.\\n3. Musk's lawsuit seeks a judicial determination that GPT-4 (a product of OpenAI) constitutes Artificial General Intelligence (AGI) and is outside the scope of OpenAI's license to Microsoft.\\n4. The lawsuit alleges that the new OpenAI board, handpicked by Altman and Microsoft, is unlikely to declare that AGI has been reached, allowing Microsoft to continue profiting from the technology.\\n5. Musk donated $44 million to help start OpenAI and recruit leading AI researchers. The lawsuit is filed to compel OpenAI to adhere to its founding agreement and return to its mission of developing AGI for the benefit of humanity.\\n\\nThese are the main points surrounding the lawsuit between Elon Musk and OpenAI. If you would like more information or further details, please let me know!\"), HumanMessage(content='Explain spinoza’s god'), AIMessage(content=\"Baruch Spinoza, a prominent Dutch philosopher of the Age of Reason, introduced a unique concept of God in his philosophy. Spinoza's concept of God can be summarized as follows:\\n\\n1. **Pantheism**: Spinoza's God can be described as a pantheistic view where God is identified with the natural world and the universe as a whole. In Spinoza's philosophy, God and nature are one and the same. God is not a personal deity separate from the universe but is immanent in all things.\\n\\n2. **Substance Monism**: Spinoza proposed the concept of substance monism, which means that there is only one substance in the universe, and that substance is God or nature. According to Spinoza, everything that exists is a manifestation of this one substance.\\n\\n3. **Immutable and Infinite**: Spinoza's God is characterized as an immutable and infinite substance. God is not subject to change or emotions but is a necessary and eternal entity that encompasses all of reality.\\n\\n4. **Causal Determinism**: Spinoza's God is also associated with the concept of causal determinism, where all events and phenomena in the universe are determined by the laws of nature and the attributes of God. This deterministic view suggests that everything unfolds according to a predetermined order.\\n\\n5. **Ethical Implications**: Spinoza's philosophy of God has ethical implications as well. He believed that understanding and aligning oneself with the laws of nature (God) leads to a life of harmony and ethical living. By recognizing the interconnectedness of all things as manifestations of God, individuals can strive for a more rational and virtuous existence.\\n\\nOverall, Spinoza's concept of God challenges traditional anthropomorphic views of a personal deity and instead presents a philosophical framework where God is synonymous with the natural world, existing as a unified and all-encompassing entity.\"), HumanMessage(content='Please search and explain spinoza’s god'), AIMessage(content='Baruch Spinoza, also known as Benedictus de Spinoza, was a Jewish Dutch philosopher who significantly influenced modern biblical criticism, Rationalism, and conceptions of the self and the universe. He challenged traditional religious beliefs and was expelled from the Jewish community for defying rabbinic authorities. Spinoza\\'s philosophy encompassed various areas, including metaphysics, epistemology, political philosophy, ethics, and philosophy of mind.\\n\\nOne of Spinoza\\'s notable works is \"Ethics, Demonstrated in Geometrical Order,\" where he applied Euclid\\'s method in philosophy. In this work, Spinoza presented a small number of definitions and axioms from which he derived numerous propositions and corollaries, such as exploring the relationship between the mind, power, freedom, and eternity.\\n\\nRegarding Spinoza\\'s concept of God, he is often associated with pantheism, where God is identified with the natural world and the universe as a whole. Spinoza\\'s God is characterized as an immutable and infinite substance, representing the unity of all things in the universe. Spinoza\\'s God is not a personal deity but is immanent in all aspects of reality, emphasizing the interconnectedness of all existence.\\n\\nAlbert Einstein, a renowned physicist, expressed admiration for Spinoza\\'s concept of God, stating, \"I believe in Spinoza\\'s God.\" Einstein saw God as a universal force or lawgiver rather than a personal deity involved in human affairs. Einstein\\'s views on religion and God were aligned with Spinoza\\'s philosophical ideas, emphasizing a non-personal and transcendent understanding of the divine.\\n\\nSpinoza\\'s philosophy of God challenges conventional anthropomorphic views and presents a holistic and interconnected vision of the universe, where God is synonymous with nature and all of existence.'), HumanMessage(content='Can you please query the top 1 processed_articles table'), AIMessage(content='The top processed article in the database is as follows:\\n\\n- **Title**: Pittsburgh Hockey Now: Your Ultimate Destination for Pittsburgh Penguins News and Analysis\\n- **URL**: [Pittsburgh Hockey Now](https://pittsburghhockeynow.com/pittsburgh-penguins-links-week-in-review-crosby-bruins-capitals-sabres/)\\n- **Summary**: Pittsburgh Hockey Now is the premier online destination for all things related to the Pittsburgh Penguins. From game analysis and player profiles to news and features, they cover a wide range of topics related to the Pittsburgh Penguins.\\n- **Date and Time**: January 26, 2024, 7:19:38 AM (UTC)\\n\\nIf you need more information or have any specific questions about this article or any other topic, feel free to ask!')]\n"
]
}
],
"source": [
"vortex_session = VortexSession(session_factory=get_db_context())\n",
"agent = vortex_session.get_or_create_agent(user_id='+573017758620')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"agent.get_response('please query the top 1 articles_summary table')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "vortex",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 67cb2e6

Please sign in to comment.