Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replicate support #248

Merged
merged 18 commits into from
Dec 19, 2023
Merged

feat: replicate support #248

merged 18 commits into from
Dec 19, 2023

Conversation

Kartik1397
Copy link
Contributor

@Kartik1397 Kartik1397 commented Dec 15, 2023

closes #242

/claim #242

@Kartik1397 Kartik1397 changed the title [WIP}feat: replicate support [WIP]feat: replicate support Dec 15, 2023
@Kartik1397 Kartik1397 changed the title [WIP]feat: replicate support feat: replicate support Dec 16, 2023
@Kartik1397 Kartik1397 marked this pull request as ready for review December 16, 2023 10:25
Copy link
Member

@nirga nirga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for this @Kartik1397! Wrote a couple of comments. I'd also suggest actually testing this against app.traceloop.com because I'm not sure it will work as expected currently. You can build a new simple sample app for that.

@Kartik1397
Copy link
Contributor Author

Thanks, @nirga for reviewing the PR! I've incorporated your feedback in my latest commit. Please let me know if there's still anything missing or can be done in better way. This is my first time using OpenTelemetry SDK, I may have overlooked some straightforward aspects. Your guidance is greatly appreciated!

Testing on api.traceloop.com

output2.mp4

Copy link
Member

@nirga nirga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Can you just add the sample app you used?

"stability-ai/stable-diffusion:27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478",
input={"prompt": "robots"}
)
print(image)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove

Copy link
Contributor Author

@Kartik1397 Kartik1397 Dec 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirga Should I remove all print statements from this test file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kartik1397 yes, these aren't printed anyway

@Kartik1397
Copy link
Contributor Author

Perfect! Can you just add the sample app you used?

Should I add it to https://github.com/traceloop/openllmetry/tree/main/packages/sample-app/sample_app?

@nirga
Copy link
Member

nirga commented Dec 17, 2023

Perfect! Can you just add the sample app you used?

Should I add it to https://github.com/traceloop/openllmetry/tree/main/packages/sample-app/sample_app?

Yes!

@Kartik1397
Copy link
Contributor Author

Done @nirga. Also reduced minimum python version required for opentelemetry-instrumentation-replicate to 3.8 as replicate support python 3.8. https://pypi.org/project/replicate/

colorama = "^0.4.6"
tenacity = "^8.2.3"
pydantic = "^2.5.0"
jinja2 = "^3.1.2"
deprecated = "^1.2.14"
posthog = "^3.0.2"
replicate = "^0.22.0"
Copy link
Member

@nirga nirga Dec 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be a dependency of the SDK, just a test dependency (under tool.poetry.group.test.dependencies)

@nirga
Copy link
Member

nirga commented Dec 17, 2023

@Kartik1397 when installing the SDK there's a warning
Warning: poetry.lock is not consistent with pyproject.toml. You may be getting improper dependencies. Run poetry lock [--no-update] to fix it. (see checks logs).

Also, I'm not sure your code will work for streaming - have you tested it?

@Kartik1397
Copy link
Contributor Author

@Kartik1397 when installing the SDK there's a warning
Warning: poetry.lock is not consistent with pyproject.toml. You may be getting improper dependencies. Run poetry lock [--no-update] to fix it. (see checks logs).

This should be fixed now.

Also, I'm not sure your code will work for streaming - have you tested it?

I can see traces of stream function calls are getting consumed by traceloop(with propmpts). Do we need to capture response in case of streaming API?

Screenshot 2023-12-18 at 7 54 24 PM
{
    "name": "replicate.stream",
    "context": {
        "trace_id": "0x0e03350bb8f375674076a774eb4d964f",
        "span_id": "0x84224c4e5915e5b4",
        "trace_state": "[]"
    },
    "kind": "SpanKind.CLIENT",
    "parent_id": "0x21c7475439b11a24",
    "start_time": "2023-12-18T14:36:54.448065Z",
    "end_time": "2023-12-18T14:36:54.448092Z",
    "status": {
        "status_code": "OK"
    },
    "attributes": {
        "llm.vendor": "Replicate",
        "llm.request.type": "completion",
        "traceloop.workflow.name": "chat_stream_generator",
        "llm.request.model": "meta/llama-2-70b-chat:02e509c789964a7ea8736978a43525956ef40397be9033abf9fd2badfe68c9e3",
        "llm.prompts.0.user": "tiny robot"
    },
    "events": [],
    "links": [],
    "resource": {
        "attributes": {
            "service.name": "sample_app/replicate_streaming.py"
        },
        "schema_url": ""
    }
}

@nirga
Copy link
Member

nirga commented Dec 18, 2023

@Kartik1397 when installing the SDK there's a warning
Warning: poetry.lock is not consistent with pyproject.toml. You may be getting improper dependencies. Run poetry lock [--no-update] to fix it. (see checks logs).

This should be fixed now.

Also, I'm not sure your code will work for streaming - have you tested it?

I can see traces of stream function calls are getting consumed by traceloop(with propmpts). Do we need to capture response in case of streaming API?

Screenshot 2023-12-18 at 7 54 24 PM ``` { "name": "replicate.stream", "context": { "trace_id": "0x0e03350bb8f375674076a774eb4d964f", "span_id": "0x84224c4e5915e5b4", "trace_state": "[]" }, "kind": "SpanKind.CLIENT", "parent_id": "0x21c7475439b11a24", "start_time": "2023-12-18T14:36:54.448065Z", "end_time": "2023-12-18T14:36:54.448092Z", "status": { "status_code": "OK" }, "attributes": { "llm.vendor": "Replicate", "llm.request.type": "completion", "traceloop.workflow.name": "chat_stream_generator", "llm.request.model": "meta/llama-2-70b-chat:02e509c789964a7ea8736978a43525956ef40397be9033abf9fd2badfe68c9e3", "llm.prompts.0.user": "tiny robot" }, "events": [], "links": [], "resource": { "attributes": { "service.name": "sample_app/replicate_streaming.py" }, "schema_url": "" } } ```

Yes, of course :) Same as we do in OpenAI.

@Kartik1397
Copy link
Contributor Author

Okay, will add support for streaming.

@Kartik1397
Copy link
Contributor Author

Pushed changes to capture response streams.

@nirga
Copy link
Member

nirga commented Dec 19, 2023

Failed as Github doesn't recognize newly added Replicate API token. Tested locally.
Merging.

@nirga nirga merged commit 6014dc0 into traceloop:main Dec 19, 2023
2 of 6 checks passed
5war00p pushed a commit to 5war00p/openllmetry that referenced this pull request Dec 20, 2023
Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>
5war00p pushed a commit to 5war00p/openllmetry that referenced this pull request Dec 24, 2023
Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>
5war00p pushed a commit to 5war00p/openllmetry that referenced this pull request Dec 24, 2023
Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>
5war00p pushed a commit to 5war00p/openllmetry that referenced this pull request Dec 24, 2023
Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>
5war00p pushed a commit to 5war00p/openllmetry that referenced this pull request Dec 24, 2023
Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 Feature: Replicate Instrumentation
2 participants