Python and OpenAI functions

Hi all

Not sure if I am requesting something bizarre here.
I trying to make a fun TelegramBot using OpenAI.

I have already used the pre-built OpenAI connector, but now i am looking for something specific, using python. Online i have found two functions from the openai library in python:

from openai.embeddings_utils import get_embedding
and
from openai.embeddings_utils import cosine_similarity

Basically, these functions can do some magic.
I have tried to add these to a step, but it dit not work out.
Is this too much? To run complete python scripts?
Not sure if Pipedrive is ment to do stuff like this

Hello @dirkpeterc,

May I ask for specific error that you’re facing? You can read through about importing Python package into Pipedream code step via this link: Python - Pipedream

Hey!

I got error-message that some libraries where not found.
I found via Github the libraries which where used by the embeddings_utils package, add manually added these as well.

Now it works!

import openai
import pandas as pd
import numpy as np
openai.api_key = [my-key]’

import matplotlib.pyplot as plt
import plotly.express as px
from scipy import spatial
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
from sklearn.metrics import average_precision_score, precision_recall_curve
from tenacity import retry, stop_after_attempt, wait_random_exponential

from openai.embeddings_utils import get_embedding

from openai.embeddings_utils import cosine_similarity

f = get_embedding(“the fox crossed the road”, engine=‘text-embedding-ada-002’)

print(f)

Before i build further; should I worry at all about the runtime(?) of the script if i start to calculate these operations for 1.000 rows?

1 Like

Hi @dirkpeterc,

You can select Python version in your Python code step. In more detail, Pipedream runs your code step in an AWS Lambda function, so AWS Lambda limits will applies (.i.e computation time). Also Pipedream has some limit on memory. You can read more about it here: Limits