Skip to content

Instantly share code, notes, and snippets.

View Cdaprod's full-sized avatar
🏠
Learn something new everyday!

David Cdaprod

🏠
Learn something new everyday!
View GitHub Profile
@Cdaprod
Cdaprod / OUTPUT.md
Created February 17, 2024 18:42 — forked from isaacarnault/OUTPUT.md
Data collection using Python

Data collection using Python

See output

isaac-arnault-data-collection-P.png

@Cdaprod
Cdaprod / AutoGen+Ollama-Instructions.txt
Last active December 13, 2023 20:24 — forked from mberman84/gist:ea207e7d9e5f8c5f6a3252883ef16df3
AutoGen + Ollama Instructions
1. # create new .py file with code found below
2. # install ollama
3. # install model you want “ollama run mistral”
4. conda create -n autogen python=3.11
5. conda activate autogen
6. which python
7. python -m pip install pyautogen
7. ollama run mistral
8. ollama run codellama
9. # open new terminal
from langchain.document_loaders import YoutubeLoader
from langchain.indexes import VectorstoreIndexCreator
loader = YoutubeLoader.from_youtube_url("https://www.youtube.com/watch?v=fLn-WqliEQU&lc=UgyOc6oNr_4-YLGCL2R4AaABAg", add_video_info=False)
docs = loader.load()
index = VectorstoreIndexCreator()
index = index.from_documents(docs)
from langchain.document_loaders import YoutubeLoader
from langchain.indexes import VectorstoreIndexCreator
urls = [
("https://www.youtube.com/watch?v=fP6vRNkNEt0", "Prompt Injection"),
("https://www.youtube.com/watch?v=qWv2vyOX0tk", "Low Code-No Code"),
("https://www.youtube.com/watch?v=k8GNCCs16F4", "Agents In Production"),
("https://www.youtube.com/watch?v=1gRlCjy18m4", "Agents"),
("https://www.youtube.com/watch?v=fLn-WqliEQU", "Output Parsing"),
("https://www.youtube.com/watch?v=ywT-5yKDtDg", "Document QA"),
("https://www.youtube.com/watch?v=GrCFyyyAxCU", "SQL"),
from langchain.chat_models import ChatOpenAI
from pydantic import BaseModel, Field
from langchain.document_loaders import UnstructuredURLLoader
from langchain.chains.openai_functions import create_extraction_chain_pydantic
class LLMItem(BaseModel):
title: str = Field(description="The simple and concise title of the product")
description: str = Field(description="The description of the product")
def main():
from langchain.prompts import ChatPromptTemplate
from langchain.chat_models import ChatOpenAI
from langchain.schema.output_parser import StrOutputParser
from langchain.vectorstores import Chroma
from langchain.embeddings import OpenAIEmbeddings
from langchain.schema.runnable import RunnablePassthrough
from langchain.schema.runnable import RunnableMap
from langchain.schema import format_document
from typing import AsyncGenerator
from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.llms import OpenAI
llm = OpenAI(temperature=0, model="gpt-3.5-turbo-instruct")
from metaphor_python import Metaphor
client = Metaphor("")
from langchain.prompts import PromptTemplate
from langchain.chat_models import ChatAnthropic
from langchain.schema.output_parser import StrOutputParser
#### ROUTER
# This is the router - responsible for chosing what to do
chain = PromptTemplate.from_template("""Given the user question below, classify it as either being about `weather` or `other`.
Do not respond with more than one word.
from langchain.chains.openai_functions import create_structured_output_runnable
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.pydantic_v1 import BaseModel, Field
class Insight(BaseModel):
insight: str = Field(description="""insight""")
chat_model = ChatOpenAI(model_name="gpt-4-1106-preview")
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
import requests
from bs4 import BeautifulSoup
from langchain.schema.runnable import RunnablePassthrough, RunnableLambda
from langchain.utilities import DuckDuckGoSearchAPIWrapper
import json
RESULTS_PER_QUESTION = 3