File size: 2,501 Bytes
771502a
 
 
 
 
 
 
 
 
 
62151d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b624a7
62151d3
4b624a7
 
62151d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b624a7
62151d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
title: Transcript Analysis
emoji: 📝
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: false
---

# ml-tech-assessment

## Environment Setup

### Using Conda (Recommended)

1. Install Conda if you haven't already:
   - Download and install [Miniconda](https://docs.conda.io/en/latest/miniconda.html) or [Anaconda](https://www.anaconda.com/products/distribution)

2. Create and activate a new conda environment:
   ```bash
   conda create -n ml-assessment python=3.12
   conda activate ml-assessment
   ```

## Installing Poetry and Dependencies

1. Install Poetry using pip:
   ```bash
   pip install poetry
   ```

2. Install project dependencies:
   ```bash
   poetry install
   ```

## Environment Variables

1. Create a `.env` file in the root directory of the project
2. Add the OpenAI API key and optional model:

```env
OPENAI_API_KEY=your-openai-api-key
OPENAI_MODEL=gpt-4o-2024-08-06
```

## Running Tests

To run the tests, make sure you have:
1. Activated your virtual environment
2. Installed all dependencies using Poetry
3. Created and populated the `.env` file

Then run:
```bash
pytest
```

For more detailed test output:
```bash
pytest -v
```

For test coverage report:
```bash
pytest --cov
```

## Running the API

Start the FastAPI application with:

```bash
poetry run uvicorn app.main:app --reload
```

If Poetry is not installed globally but dependencies are already installed in the local virtual environment, run:

```bash
./.venv/bin/uvicorn app.main:app --reload
```

Swagger documentation is available at:

```text
http://127.0.0.1:8000/docs
```

The Gradio frontend is available at:

```text
http://127.0.0.1:8000/
```

Analyze one transcript:

```bash
curl -G "http://127.0.0.1:8000/analyses" \
  --data-urlencode "transcript=Discuss the launch plan and assign next steps."
```

Retrieve a stored analysis:

```bash
curl "http://127.0.0.1:8000/analyses/<analysis-id>"
```

Analyze multiple transcripts concurrently:

```bash
curl -X POST "http://127.0.0.1:8000/analyses/batch" \
  -H "Content-Type: application/json" \
  -d '{"transcripts":["Discuss launch risks.","Review onboarding plan."]}'
```

Analysis results are stored in memory, so they reset when the API process restarts.

## OpenAI Adapter Integration Test

The live OpenAI adapter test is skipped by default so local test runs do not require network access or credentials. To run it explicitly:

```bash
RUN_OPENAI_INTEGRATION_TESTS=1 poetry run pytest tests/adapters/test_openai.py
```