Views
No views yet
Create a component diagram for a platform to buy and sell games between users.componentDiagram
package "Services" {
[Game Service]
[User Service]
}
database "Storage" {
[Games Table]
[Users Table]
}
[Game Service] --> [Games Table]
[User Service] --> [Users Table]
[Game Service] --> [User Service] : for authentication
Add shopping cart and checkout service to this component diagram
componentDiagram
package "Services" {
[Game Service]
[User Service]
}
database "Storage" {
[Games Table]
[Users Table]
}
[Game Service] --> [Games Table]
[User Service] --> [Users Table]
[Game Service] --> [User Service] : for authenticationcomponentDiagram
package "Services" {
[Game Service]
[User Service]
[Shopping Cart Service]
[Checkout Service]
}
database "Storage" {
[Games Table]
[Users Table]
[Cart Items Table]
[Orders Table]
}
[Game Service] --> [Games Table]
[User Service] --> [Users Table]
[Shopping Cart Service] --> [Cart Items Table]
[Checkout Service] --> [Cart Items Table]
[Checkout Service] --> [Orders Table]
[Game Service] --> [User Service] : for authentication
[Shopping Cart Service] --> [User Service] : for authentication
[Checkout Service] --> [User Service] : for authentication
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load model
5model_name = "huytd189/pintora-coder-7b"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
8
9# Prompt template
10edit_prompt = """Pintora Diagram Edit Instruction
11
12### Instruction:
13{}
14
15{}
16
17### Response:
18{}"""
19
20# Example 1: Generate from scratch
21inputs = tokenizer([
22 edit_prompt.format(
23 "Create a component diagram for a platform to buy and sell games between users.",
24 "",
25 ""
26 )
27], return_tensors="pt").to("cuda")
28
29outputs = model.generate(**inputs, max_new_tokens=512, use_cache=True)
30print(tokenizer.batch_decode(outputs, skip_special_tokens=True)[0])
31
32print("\n" + "="*80 + "\n")
33
34# Example 2: Edit existing diagram
35inputs = tokenizer([
36 edit_prompt.format(
37 "Add shopping cart and checkout service to this component diagram",
38 """componentDiagram
39
40package "Services" {
41 [Game Service]
42 [User Service]
43}
44database "Storage" {
45 [Games Table]
46 [Users Table]
47}
48[Game Service] --> [Games Table]
49[User Service] --> [Users Table]
50[Game Service] --> [User Service] : for authentication""",
51 ""
52 )
53], return_tensors="pt").to("cuda")
54
55outputs = model.generate(**inputs, max_new_tokens=512, use_cache=True)
56print(tokenizer.batch_decode(outputs, skip_special_tokens=True)[0])