Comments (1)
I took a look into the code, and the following block of code should do the trick
def split_prompt(text, split_length):
if split_length <= 0:
raise ValueError("Max length must be greater than 0.")
num_parts = -(-len(text) // split_length)
file_data = []
for i in range(num_parts):
start = i * split_length
end = min((i + 1) * split_length, len(text))
if i == num_parts - 1:
content = f'[START PART {i + 1}/{num_parts}]\n' + text[start:end] + f'\n[END PART {i + 1}/{num_parts}]'
content += '\nALL PARTS SENT. Now you can continue processing the request.'
else:
content = f'Do not answer yet. This is just another part of the text I want to send you. Just receive and acknowledge as "Part {i + 1}/{num_parts} received" and wait for the next part.\n[START PART {i + 1}/{num_parts}]\n' + text[start:end] + f'\n[END PART {i + 1}/{num_parts}]'
content += f'\nRemember not answering yet. Just acknowledge you received this part with the message "Part {i + 1}/{num_parts} received" and wait for the next part.'
file_data.append({
'name': f'split_{str(i + 1).zfill(3)}_of_{str(num_parts).zfill(3)}.txt',
'content': content
})
return file_data
from chatgpt-prompt-splitter.
Related Issues (15)
- Messages are still too long HOT 4
- Broken English
- How to support LangChain?
- Instructions section always rendering "1/10"
- This script, and any attempt to break a long string into multiple inputs, DOES NOT and CANNOT work. ChatGPT will forget 100% of all snippets, except for the last. HOT 1
- Can this be ported to work offline on clientside?
- If the the context token limit is 8k, then wouldn't gpt start forgetting the initial chunks? HOT 1
- Auto paste chuncks? HOT 6
- Incorrect Chunk Calculation HOT 1
- Vercel deployment success, but website shows 500 error HOT 3
- Call OpenAI API directly and got this error
- Is this even working? HOT 1
- Deployment
- Deployment to Vercel Broken HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatgpt-prompt-splitter.