Skip to content

Instantly share code, notes, and snippets.

from crewai import Agent, Task, Crew, Process
from langchain.tools import tool
from langchain.llms import Ollama
from langchain_groq import ChatGroq
import os
from langchain.globals import set_debug, set_verbose
set_debug(True)
set_verbose(True)
@vcappuccio
vcappuccio / Terraform-python.md
Created December 15, 2023 15:56
Using Terraform with Python

Very easy terraform code to add two numbers together using python and save the result in a file.

You need to initialize and apply the Terraform configuration before running the script. The script will read the number from the command line and then print the result.

  • The Python script add_numbers.py adds two numbers together.
  • The Terraform script pymain.tf executes the Python script and saves the result to a file named output.txt.
  • The Terraform script uses two variables, number1 and number2, to pass arguments to the Python script.
  • To run the Terraform script, you need to initialize Terraform and apply the Terraform configuration.

Spell Checker

import sys
from langchain.llms import Ollama

ollama = Ollama(base_url='http://localhost:11434', model='mistral')

def check_text(text_to_check):
    prompt = f"Please proofread this text for grammar, style, clarity, and coherence: {text_to_check}"
from langchain.llms import Ollama
from langchain.document_loaders import WebBaseLoader
loader = WebBaseLoader("https://en.wikipedia.org/wiki/IGMP_snooping")
data = loader.load()
from langchain.text_splitter import RecursiveCharacterTextSplitter

text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)
all_splits = text_splitter.split_documents(data)
from langchain.embeddings import OllamaEmbeddings
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