Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Python artifacts
__pycache__/
*.py[cod]
*.egg-info/

# Environments
venv/
.venv/
ENV/
env/

# dotenv files
*.env

# Output files
*.docx
*.html

# Node
node_modules/

13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
This repository contains small Python utilities for interacting with AI models.
All scripts are located in the `scripts/` directory.

## Setup

Create the conda environment and install the required Python packages:

```bash
conda env create -f environment.yml
conda activate myscripts
```

## Available Scripts

- **claude_call.py** – Query Anthropic's Claude model and save results to a DOCX
Expand All @@ -14,3 +23,7 @@ All scripts are located in the `scripts/` directory.
outputs.

See [scripts/README.md](scripts/README.md) for more details on each script.

The repository also includes a simple monitoring demo located in
`monitoring-app/`. Consult its README for instructions on running the FastAPI
backend and React frontend.
22 changes: 22 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: myscripts
channels:
- conda-forge
dependencies:
- python=3.10
- pip
- pip:
- python-docx
- markdown2
- tqdm
- anthropic
- groq
- faster-whisper
- ollama
- langchain-community
- psutil
- pyjwt
- requests
- fastapi
- uvicorn
- websockets
- python-dotenv
10 changes: 5 additions & 5 deletions monitoring-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ This project provides a minimal FastAPI backend and React-based frontend for rea

### Running

Install dependencies and start:
Create the conda environment from the repository root and start the server:

```bash
conda env create -f ../../environment.yml # run once
conda activate myscripts
cd backend
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload
```

Expand All @@ -28,7 +27,8 @@ uvicorn main:app --reload

## Security Notes

- Change `SECRET_KEY`, `ADMIN_USER`, and `ADMIN_PASS` in `.env`.
- Copy `backend/.env.example` to `backend/.env` and change `SECRET_KEY`,
`ADMIN_USER`, and `ADMIN_PASS`.
- Use HTTPS termination in production.

This is a starting point for a full-featured monitoring solution.
File renamed without changes.
6 changes: 6 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This directory contains small utility scripts for working with AI models.
Each script is saved with a descriptive name and `.py` extension so they can be
run using Python.

The API-based scripts expect the relevant keys to be provided as environment
variables:

- `ANTHROPIC_API_KEY` for `claude_call.py`
- `GROQ_API_KEY` for the Groq examples

## Scripts

### `claude_call.py`
Expand Down
6 changes: 3 additions & 3 deletions scripts/claude_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def generate_messages(section: str) -> List[dict]:
}
]

client: anthropic.Anthropic = anthropic.Anthropic(api_key=)
client: anthropic.Anthropic = anthropic.Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY", ""))

print("Generating policy outline...")

Expand Down Expand Up @@ -60,10 +60,10 @@ def generate_messages(section: str) -> List[dict]:
word_document.add_paragraph("\n")
html_sections.append(markdown(detailed_info))

docx_file_path = "e.docx"
docx_file_path = "output.docx"
with open(docx_file_path, "wb") as doc_file:
word_document.save(doc_file)

html_file_path = ".html"
html_file_path = "output.html"
with open(html_file_path, "w") as html_file:
html_file.write("\n".join(html_sections))
8 changes: 4 additions & 4 deletions scripts/groq_simple_chatbot.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from groq import Groq
import os


# Initialize the Groq API
client= Groq(api_key="<key-here>")
# Initialize the Groq API using an environment variable
client = Groq(api_key=os.getenv("GROQ_API_KEY", ""))

# Initialize the conversation list
conversation = [
{"role": "system", "content": "You are a helpful assistant."},
]

# Function to interact with GPT-3
# Function to interact with the Groq model
def chat_with_groq(prompt, conversation):
model_engine = "mixtral-8x7b-32768"

Expand Down
10 changes: 3 additions & 7 deletions scripts/read_mp3_summary.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
from faster_whisper import WhisperModel
from groq import Groq
import os

def open_file(filepath):
with open(filepath, 'r', encoding='utf-8') as infile:
return infile.read()

API_KEY = open_file('groqapikey.txt')
client = Groq(api_key=API_KEY)
client = Groq(api_key=os.getenv("GROQ_API_KEY", ""))

def transcribe_audio(audio_path, model_size="medium"):
model = WhisperModel(model_size, device="cpu")
segments, _ = model.transcribe(audio_path)
return " ".join([segment.text for segment in segments])

audio_file_path = "/path/to/your/mp3" # Replace with your audio file path
audio_file_path = os.getenv("AUDIO_FILE", "/path/to/your/mp3")
transcribed_text = transcribe_audio(audio_file_path)
with open("transcription.txt", "w") as file:
file.write(transcribed_text)
Expand Down